Decimal string to floating point conversion with correct half-to-even rounding

Dukc ajieskola at gmail.com
Mon Jun 22 12:41:20 UTC 2020


On Monday, 22 June 2020 at 12:07:26 UTC, 9il wrote:
> On Monday, 22 June 2020 at 12:04:13 UTC, 9il wrote:
>> So the algorithm would look like:
>> 1. Parse hexadecimal big integer
>> 2. Parse exponent
>> 3. Cast big integer to `Fp` with a specific number of 
>> meaningful bits (its already implemented)
>> 4. Add exponent to `Fp`'s exponent, and cast the result to a 
>> hardware floating point type.
>
> My bad, the hexadecimal parsing is already implemented for big 
> integers!
>
> http://mir-algorithm.libmir.org/mir_bignum_low_level_view.html#.BigUIntView.fromHexStringImpl
>

So only a bit left to go. Great!

> So, each part of the algorithm above is implemented. Maybe we 
> need to rework fromHexStringImpl to make it return a boolean 
> value.

Good idea. It should pay back when one wants to parse a big 
amount of strings that are likely to contain a lot of 
non-integers.


More information about the Digitalmars-d-announce mailing list