‎04-08-2005 11:25 AM
‎04-08-2005 02:01 PM
‎04-08-2005 02:07 PM
‎12-16-2013 12:48 PM - edited ‎12-16-2013 12:55 PM
ScanFile (InputString, "%s>%f", &DoubleValue);
Is there not a modifier (or set of modifiers) either on the source string variable and/or the target double variable that will get rid of this problem?
My input char string is always something like -12.5000 or -9.3500 (always four digits after the decimal).
Sometimes it nails it with all zeros, and sometimes I get -12.500000000000001 or -9.350000000000001.
The code is a solution of course (and what I'm doing now), but not very elegant...
‎12-17-2013 08:00 AM
Here's what I ended up with.
Value *= 10000; // Turns the important part into a integer (up to 4 decimal places).
modf (Value, &Value); // Gets rid of any remainder.
Value /= 10000; // Turns Value back into the original number without the conversion error.