![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Rounding off the value of Floating point value | damansingh | Shell Programming and Scripting | 7 | 05-21-2008 06:46 AM |
| Floating point exception !!! | ssk01 | Linux | 2 | 05-14-2008 02:58 AM |
| floating point problem | vijlak | High Level Programming | 4 | 03-08-2007 12:18 AM |
| floating point addition | ravi raj kumar | Shell Programming and Scripting | 8 | 12-21-2006 10:47 PM |
| Floating Point Division | gsatch | Shell Programming and Scripting | 1 | 07-25-2002 01:03 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Floating point error in C
Hi,
see the simple code below double i; i=8080.9940; printf(" val :%.30f\n",i); output i m getting is val :8080.993999999999700000000000000 when i m expecting val :8080.9940 what happens?how can i avoid it? thanks... |
| Forum Sponsor | ||
|
|
|
||||
|
Hi,
You can try this code and will give the exact output which you are expecting double i; i=8080.9940; printf(" val :%.4f\n",i); Why because if you given %.30f it will consider 30 digit for fraction value so instead of %.30f we can use %.4f. Let me know in case of any dificulties Regards, MPS |
||||
| Google The UNIX and Linux Forums |