[fixed] fast_atof bug

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
RVL
Posts: 5
Joined: Sat Jun 09, 2007 11:12 am

[fixed] fast_atof bug

Post by RVL »

The function parses negative exponents incorrectly. It doesn't take into account a possible '-' sign just before exponent value.
Current SVN:

Code: Select all

   85 		if (*c == 'e')
   86 		{
   87 			++c;
   88 			//float exp = (float)strtol(c, &t, 10);
   89 			float exp = (float)strtol10(c, t);
   90 
   91 			f *= (float)pow(10.0f, exp);
   92 			c = t;
   93 		}
Corrected variant:

Code: Select all

		if (*c == 'e')
		{
			++c;
			//float exp = (float)strtol(c, &t, 10);
			bool einv = (*c=='-');
			if (einv) c++;

			float exp = (float)strtol10(c, t);
			if (einv)
				exp *= -1.0f;

			f *= (float)pow(10.0f, exp);
			c = t;
		}
[/code]
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

fixed in revision 702.

i recently reported a bug on wings3d regarding this, that the obj exporter exports doubles rather than floats.
i guess i should have looked closer to home first :oops:
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply