On Thursday 03 March 2005 16:33, Nicolai Haehnle wrote: > Hi, > > I'm in the process of merging the software model into ogsim (and using 100% > common code), and I noticed a bug in float25::approx_recp. > > The case where mantissa == 0 is not handled correctly, the exponent of the > result is off by one (1/0.5 return 1.0, for example). The following patch > should fix that, but please check if there are any other corner cases that > might be problematic. If there are no objections, I'll commit soon. > > --- float25.cpp (revision 14) > +++ float25.cpp (working copy) > @@ -86,7 +86,8 @@ > > invfrac = (((mantissa & 0x3F) ^ 0x3F) + 1); > mantissa = base + ((difference * invfrac) >> 3); > - } > + } else > + exponent--; > > exponent = ((~exponent) - 2) & 0xFF;
You're right, it is a bug, and this is the correct solution. As for corner cases, it doesn't work correctly for NaNs, infinity, and denormalised numbers. We should check the pipeline to make sure that these can't happen, or if they do, they should be handled. There is another thing. The code in the float25 class is not my latest approximate reciprocal code. Its precision is very limited, probably not enough to get good quality results. However, it's probably good to leave it in there just to test. I will try to merge my two-table 18-bit version into the model next week. That doesn't affect anything else though, so feel free to commit this in the mean time. Lourens _______________________________________________ Open-graphics mailing list [email protected] http://lists.duskglow.com/mailman/listinfo/open-graphics List service provided by Duskglow Consulting, LLC (www.duskglow.com)
