02-02-2015
Quote:
Originally Posted by
rohit_shinez
i[..]
I mean will there be any better approach apart from mine
It seems like a good approach to me..
This User Gave Thanks to Scrutinizer For This Post:
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello,
In a unix shell script,i want to round a variabele to a nearest number
Ex: set count=104.4
How can i round that to 105.?
Thanks,
Sateesh (2 Replies)
Discussion started by: kotasateesh
2 Replies
2. Shell Programming and Scripting
Is there an easy way to round a number up in Korn shell?
ie. 10.4 --> 11
Thanks. (6 Replies)
Discussion started by: here2learn
6 Replies
3. Shell Programming and Scripting
In a shell script - How do I round a decimal number (contained in a variable) to the nearest whole number? (2 Replies)
Discussion started by: achieve
2 Replies
4. Shell Programming and Scripting
my $number = 12.345673412 I need 3 digits after decimal or after dot(.)
i mean , i need only 12.345
I used int(), ceil(), floor() but it gives me only 12
I need it. (10 Replies)
Discussion started by: pritish.sas
10 Replies
5. Shell Programming and Scripting
Hi
I need to create a script that distributes in round robin fashion the contents of a file to 3 files. The number of lines in a content of file can vary from 1-n(Each line is just a one letter word).The entire lines needs to get distributed into 3 files ( The order doesnt matter) , at... (5 Replies)
Discussion started by: police
5 Replies
6. Shell Programming and Scripting
HI,
I have a script which is used to calculate the Memory & CPU utilization a server.
memx=`ssh -l siebel1 ${f} /usr/sbin/prtconf|grep -i 'Memory size'|tr -s " "|/usr/xpg4/bin/awk -F" " '{print $3 * 1024}'`
v5=`ssh -l siebel1 ${f} vmstat 1 2 | tail -1 | tr -s " " | /usr/xpg4/bin/awk -v... (3 Replies)
Discussion started by: dear_abhi2007
3 Replies
7. Shell Programming and Scripting
I have a file with a list of config files numbered on the lefthand side 1-300. I need to have bash read each lines number and assign it to a variable so it can be chosen by the user called by the script later.
Ex. 1 some data
2 something else
3 more stuff
which number do you... (1 Reply)
Discussion started by: glev2005
1 Replies
8. Shell Programming and Scripting
Hey everyone, I was wondering if i am able to write a sed command to round a number to two decimal places. So for example:
1.58674
would be
1.58
I just want to chop off the numbers to the right of the second digit after the period. I know this is probably trivial but the closest i got was... (8 Replies)
Discussion started by: GmGeubt
8 Replies
9. UNIX for Dummies Questions & Answers
I have the following script:
awk 'FNR==NR{s+=$3;next;} { print $1 , $2, 100*$3/s }'
and the following file:
>P39PT-1224 Freq 900
cccctacgacggcattggtaatggctcagctgctccggatcccgcaagccatcttggatatgagggttcgtcggcctcttcagccaagg-cccccagcagaacatccagctgatcg
>P39PT-784 Freq 2... (2 Replies)
Discussion started by: Xterra
2 Replies
LEARN ABOUT HPUX
fe_dec_getround
fe_dec_getround(3M) fe_dec_getround(3M)
NAME
fe_dec_getround() - get decimal floating-point rounding direction mode
SYNOPSIS
DESCRIPTION
The function gets the current decimal rounding direction.
The default decimal rounding direction mode is round to nearest with half-way cases away from zero
These math functions are supported for HP-UX 11i Version 3 September 2008 Update and forward.
USAGE
To use this function, compile with the option.
Make sure your program defines and then includes
Specify on the compiler command line or place the call to this function under the effect of an affirmative pragma:
If the pragma is placed outside of any top-level declarations in a file, the pragma will apply until another pragma is encountered or until
the end of the file is reached.
If the pragma is placed at the beginning of a block (compound statement), the pragma will apply until another pragma is encountered or
until the end of the block is reached.
Link in the math library by specifying or on the linking command line.
For more information, see the at the following site:
RETURN VALUE
The function returns the value of the decimal rounding direction macro representing the current decimal rounding direction. The return
value will match one of the following macros, which are defined in
Round to nearest. If the two nearest representable are equally near,
the one with its least significant bit zero is delivered.
Round to nearest. If the two nearest representable are equally near,
the one furthest from zero is delivered.
Round upwards (towards +infinity).
Round downwards (towards -infinity).
Round toward zero.
ERRORS
No errors are defined.
EXAMPLES
Save, set, and restore the decimal rounding direction.
SEE ALSO
fe_dec_setround(3M), fenv(5).
STANDARDS CONFORMANCE
This function conforms to ISO/IEC TR 24732, "Extension for the programming language C to support decimal floating-point arithmetic".
fe_dec_getround(3M)