The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 01-02-2009
JerryHone JerryHone is offline
Registered User
  
 

Join Date: Nov 2006
Location: UK
Posts: 178
Rounding

Rounding!

Try this...

awk 'BEGIN {printf("%.50f\n", 326.4*100)}'

and you should see something like...

32639.99999999999636202119290828704833984375000000000000

Including the int function simply rounds the output down to 32639. 'int' does not round to the nearest integer

printf (or sprintf) rounds by default when using %f, so without the int, it will display 32640.

HTH.

Jerry