## [Sdcc-user] Denormalized floating point in SDCC.

 [Sdcc-user] Denormalized floating point in SDCC. From: Mark Rages - 2006-07-14 01:03:50 ```I posted a bug about this, but I want to bring it up here for other SDCC users to know about. The floating point routine in fsmul.c does not handle denormalized numbers well. I discovered this by doing: float f=1.0; while (1) { f*=0.25; } I expected f to decay to zero, but instead it wrapped around to a huge number! From looking at the source (device/lib/pic16/libsdcc/float/fsmul.c, but similar code for other architectures) I see there is no attemp at bounds checking when the exponents are being added together. So multiplying two numbers with very negative exponents can wrap to a very large positive exponent. It is also possible to get an infinite result, since the IEEE standard dedicates an exponent value to this. I found the source code's ancestor in GCC (3.3 or earlier). This code has the same problem in the multiply routine. Most GCC platforms have hardware floating-point support, so the code isn't used. In my code, I can work around this: #define SMALL_NUMBER 0.000001 float f=1.0; while (1) { if (f

 [Sdcc-user] Denormalized floating point in SDCC. From: Mark Rages - 2006-07-14 01:03:50 ```I posted a bug about this, but I want to bring it up here for other SDCC users to know about. The floating point routine in fsmul.c does not handle denormalized numbers well. I discovered this by doing: float f=1.0; while (1) { f*=0.25; } I expected f to decay to zero, but instead it wrapped around to a huge number! From looking at the source (device/lib/pic16/libsdcc/float/fsmul.c, but similar code for other architectures) I see there is no attemp at bounds checking when the exponents are being added together. So multiplying two numbers with very negative exponents can wrap to a very large positive exponent. It is also possible to get an infinite result, since the IEEE standard dedicates an exponent value to this. I found the source code's ancestor in GCC (3.3 or earlier). This code has the same problem in the multiply routine. Most GCC platforms have hardware floating-point support, so the code isn't used. In my code, I can work around this: #define SMALL_NUMBER 0.000001 float f=1.0; while (1) { if (f