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

9il ilyayaroshenko at gmail.com
Mon Jun 22 12:07:26 UTC 2020


On Monday, 22 June 2020 at 12:04:13 UTC, 9il wrote:
> On Monday, 22 June 2020 at 10:53:02 UTC, Dukc wrote:
>> On Sunday, 21 June 2020 at 15:24:14 UTC, 9il wrote:
>> Can mir_parse handle other bases than decimal?
>
> No, only the decimal basis is supported for now. Support for 
> hexadecimal FP/integer parsing can be added though.
>
> The basic stuff for correct FP hexadecimal parsing is done: we 
> can convert a big integer view to FP number with half-to-even 
> rounding.
>
> 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, each part of the algorithm above is implemented. Maybe we 
need to rework fromHexStringImpl to make it return a boolean 
value.


More information about the Digitalmars-d-announce mailing list