![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem in division | rochitsharma | UNIX for Dummies Questions & Answers | 9 | 1 Week Ago 07:17 PM |
| display the result of wc -l with words before and after the result | melanie_pfefer | UNIX for Dummies Questions & Answers | 3 | 04-30-2008 04:33 AM |
| Outputting formatted Result log file from old 30000 lines result log<help required> | vikas.iet | Shell Programming and Scripting | 5 | 12-02-2007 07:43 PM |
| Cannot adjust division | jav_v | Filesystems, Disks and Memory | 1 | 08-20-2002 05:50 AM |
| division problem | inquirer | Shell Programming and Scripting | 3 | 04-02-2002 07:03 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
how to get exact result in my division
Hello Friends,
Why I am not getting exact result in the following division. It is rounding off automatically. Is there any way to get the exact result or can be set by user to get how many digits to carry after the decimal. Code:
gawk '{
wait_ns1 = (82290 +1 )/78 # actuall result = 1055.012821
wait_ns2 = (82320 +1 )/78 # actuall result = 1055.397436
wait_ns3 = (82350 +1 )/78 # actuall result = 1055.782051
print wait_ns1;
print wait_ns2;
print wait_ns3;
} ' my_file
Code:
1055.01 1055.4 1055.78 Or How to get the actuall result ,ie, Code:
1055.012821 1055.397436 1055.782051 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
you can try this
Code:
nawk '
{
wait_ns1 = (82290 +1 )/78;
printf("%10.6f\n", wait_ns1);
}'
|
|
#3
|
|||
|
|||
|
Code:
# gawk 'BEGIN {OFMT = "%.6f"; print (82290 +1 )/78 ;}'
1055.012821
|
|
#4
|
|||
|
|||
|
Thank You BOSS..
|
|||
| Google The UNIX and Linux Forums |