## Rounding off to the next whole number

Rounding off to the next whole number
# 1
07-17-2008
Rounding off to the next whole number

Hello,
I searched a lot on this Forum.

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 be deeply appreciated.
 damansingh View Public Profile for damansingh Find all posts by damansingh
# 2
07-17-2008
 mirusnet View Public Profile for mirusnet Find all posts by mirusnet
# 3
07-17-2008
Humm, if you really want to round 10.8/5 to an integer the answer should be 2 not 3. What you are looking for is to round up i.e. ceil(10.8/5)

 fpmurphy View Public Profile for fpmurphy Find all posts by fpmurphy

## [awk] rounding a float number?

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=\$((...

## Rounding off to the nearest floating number

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...

## Rounding up to nearest whole number

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

## Rounding number, but....

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...

## PERL - rounding fractional number

It seems that perl sprintf uses the round-to-even method: foreach my \$i ( 0.5, 1.5, 2.5, 3.5 ) { printf "\$i -> %.0f\n", \$i; } __END__ 0.5 -> 0 1.5 -> 2 2.5 -> 2 3.5 -> 4 4.5 -> 4 Where we probably wants to use round-half-up, i.e. output should be as below: 0.5 -> 1 1.5 -> 2...

## Rounding a decimal

Hi, I am currently using tcsh I am trying to round a decimal number to the ten-thousandths place For instance: 1.23456 is rounded up towards 1.2346 I am not looking for truncation, but for rounding. Anyone know how to do this with awk or expr? Thanks

## Rounding Script Help

I need some help with my rouding script. I have started pretty much from scratch and have no idea if its correct or even close but I have been trying and have gotten to this point. i keep getting syntax errors and im not sure what is wrong. Here is what I got let value=\$1; while do let...

## Rounding Script Help

I need some help with my rouding script. I have started pretty much from scratch and have no idea if its correct or even close but I have been trying and have gotten to this point. i keep getting syntax errors and im not sure what is wrong. Here is what I got let value=\$1; while do let...

## Rounding off decimals to the nearest number in PERL

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...

## Rounding off using BC.

Hello again. I'm trying to use BC to calculate some numbers in a shell script. I want to have the numbers rounded off to 1 decimal place. for example: initsize=1566720 zipsize=4733 I'm trying to get the ratio between them. the equation is: ((\$initsize-\$zipsize)/\$initsize)*100 so...