![]() |
| | #1 |
| Registered User Join Date: Jul 2009
Posts: 2
| atof conversion error I call atof with a string of "18.69". The result is 18.690000534. Why ? Do I have to come up with a wrapper function if I am always working with figures out to two decimal places and want just that - just 18.69 ? |
| codeman is offline | |
| | #2 |
| Registered User Join Date: Sep 2006
Posts: 2,501
| You can specify that the answer be printed out only to the first 2 decimal places: Code: dbl_number = 17.123456;
printf("dbl_number to two decimal places is: %.2f \n", dbl_number);
|
| Adak is offline | |
| | #3 |
| Registered User Join Date: Jul 2009
Posts: 2
| correction Foolish me. I'm assuming the conversion might be ok. It's just my IDE telling me the value is 18.690000534. I assign 18.69 to a float value, then break, and place the mouse cursor over the value. The IDE (Borland C++ Builder version 5.0 Prodfessional) says it's 18.690000534. |
| codeman is offline | |
| | #4 | |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| Quote:
| |
| tabstop is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Quantum Random Bit Generator | shawnt | C++ Programming | 62 | 06-18-2008 10:17 AM |
| Screwy Linker Error - VC2005 | Tonto | C++ Programming | 5 | 06-19-2007 02:39 PM |
| more then 100errors in header | hallo007 | Windows Programming | 20 | 05-13-2007 08:26 AM |
| Using VC Toolkit 2003 | Noobwaker | Windows Programming | 8 | 03-13-2006 07:33 AM |
| Dikumud | maxorator | C++ Programming | 1 | 10-01-2005 06:39 AM |