11-19-2010
The mathematical method is to add 0.5 and then ignore the decimal place.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
I searched a lot on this Forum.
Please help me with the below problem.
I want to divide two numbers and the result should be the next nearest whole number.
E.G. Dividing 10.8/5 ideally gives 2.16. But the result should be 3 i.e. rounded off to the next whole number.
Any help will... (2 Replies)
Discussion started by: damansingh
2 Replies
2. Shell Programming and Scripting
Hi Guys,
I am generating a statistical report , below is the snippet of the code :
Now, $nSlices stands for the time duration,meaning,the statistics will be displayed for that particular time duration. Trouble is, for certain values of $totalTime (which is the end time - start time ), i... (9 Replies)
Discussion started by: rdlover
9 Replies
3. Shell Programming and Scripting
Is there a way I can round time in perl to the nearest five minutes?
For example if I have log giving the following time stamps
23,52,30 it would rounded up to 23,55,00
and
23,50,01 would be rounded to 23,50,00 (3 Replies)
Discussion started by: borderblaster
3 Replies
4. Shell Programming and Scripting
Dear Experts,
I'm trying to find a way to round a number but in this way:
14367.577 ---> 14000
I used the following to round the number to the closer integer:
echo $var|awk '{print int($1+0.5)}'
and also:
xargs printf "%1.0f"
However, they don't work for my above... (9 Replies)
Discussion started by: Gery
9 Replies
5. UNIX for Dummies Questions & Answers
Hi all of you,
Would be great if you help me with how to round up to whole number from my input values like
2.99996,2.17890,3.00002,-2.3456,-2.7890
o/p should be like 3,2,3,-2,-3
thnks in adv!!!!
regards (3 Replies)
Discussion started by: Indra2011
3 Replies
6. Shell Programming and Scripting
Hello everyone,
Before I state my problem I would like to inform you that this is not an assignment. I'm just trying to learn some shell programming in my free time.
I'm trying to write a parking fee calculator. But I don't seem to be able to use fractional numbers. Could you please advice... (6 Replies)
Discussion started by: iwant2learn
6 Replies
7. Shell Programming and Scripting
Dear Perl users,
I need your help to solve my problem below.
I want to print the sequence number without missing number within the range.
E.g. my sequence number :
1 2 3 4 5 6 7 8 11 12 13 14
my desired output:
1 -8 , 11-14
my code below but still problem with the result:
1 - 14
1 -... (2 Replies)
Discussion started by: mandai
2 Replies
8. Shell Programming and Scripting
Hi guys,
could someone throw some light on the following behaviour of printf (I'll start with info about the system and the tool/shell/interpreter versions)?:
$ uname -a
Linux linux-86if.site 3.1.0-1.2-desktop #1 SMP PREEMPT Thu Nov 3 14:45:45 UTC 2011 (187dde0) x86_64 x86_64 x86_64... (9 Replies)
Discussion started by: elixir_sinari
9 Replies
9. Shell Programming and Scripting
I have a number, which I want to convert into the nearest floating number upto two places after the decimal point.
E.g.
1.2346 will become 1.23
but
1.2356 will become 1.24 .
Similarly
0.009 will be 0.01
and
0.001 will be 0.00 or 0.0 (not 0, wnat to keep the decimal... (1 Reply)
Discussion started by: hbar
1 Replies
10. Shell Programming and Scripting
Heyas
Trying to calculate the total size of a file by reading its bitrate.
Code snippet:
fs_expected() { #
# Returns the expected filesize in bytes
#
pr_str() {
ff=$(cat $TMP.info)
d="${ff#*bitrate: }"
echo "${d%%,*}" | $AWK '{print $1}' | head -n 1
}
t_BYTERATE=$((... (9 Replies)
Discussion started by: sea
9 Replies
fmad64(3M) fmad64(3M)
NAME
fmad64(), fmad128(), fmad32() - decimal floating multiply-add functions
SYNOPSIS
DESCRIPTION
The function returns (x*y) + z, rounded as one ternary operation: it computes the value (as if) to infinite precision and rounds once to
the result format, according to the current (decimal) rounding mode.
is a version of it takes arguments and returns a result.
is a version of it takes arguments and returns a result.
These math functions are supported for HP-UX 11i Version 3 September 2008 Update and forward.
USAGE
To use any of these functions, compile with the option.
Make sure your program defines and then includes
Link in the math library by specifying or on the linking command line.
For more information, see the at the following site:
RETURN VALUE
If x, y, or z is NaN, returns NaN.
If one of x and y is infinite, the other is zero, and z is not NaN, returns NaN and raises the invalid exception.
If x times y is an exact infinity and z is also an infinity but with the opposite sign, returns NaN and raises the invalid exception.
returns the properly signed infinity (or, in some non-default rounding direction modes, the properly signed maximum-magnitude finite num-
ber) in lieu of a value whose magnitude is too large, and raises the overflow and inexact exceptions.
raises the underflow exception whenever a result is tiny (essentially subnormal or zero) and inexact.
raises the inexact exception whenever a rounded result does not equal the mathematical result.
ERRORS
If one of x and y is infinite, the other is zero, and z is not NaN, sets to
If x times y is an exact infinity and z is also an infinity but with the opposite sign, sets to
If the correct value would overflow, sets to
SEE ALSO
math(5).
STANDARDS CONFORMANCE
These functions conform to ISO/IEC TR 24732, "Extension for the programming language C to support decimal floating-point arithmetic".
HP Integrity Server Only fmad64(3M)