Decimal floating point to binary floating point

12252018, 11:37 PM
Post: #3




RE: Decimal floating point to binary floating point
(12252018 08:32 AM)Thomas Klemm Wrote: ... in case of 8.25e84 we'd end up with: Sun code actually do this: 8.25e84 => 825e82 => 825 * 1e2 * 1e16 * 1e64 By starting the mantissa as integer, it can do fastpath trick, say 1.23e12 => 123 / 1e14 Hardware divide (assuming FE_PC53_ENV and FE_TONEAREST) guaranteed correct conversion. Above binary conversion is correct, but it is just lucky. It is possible multiplied result are off, 1 ULP or more. The slow and messy part is the correction loop, to fix the approximated binary float. This is my implementation, using normalized 96bits big float: strtodfast.c I also made a lite version that does not use arbitrary precision math to break ties. The cost is a very slight chance of wrong conversion, ± 1 ULP https://github.com/achan001/dtoafast 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)