gcd with doubles

Moritz Maxeiner via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Sep 1 05:13:02 PDT 2017


On Friday, 1 September 2017 at 09:33:08 UTC, Alex wrote:
> On Sunday, 27 August 2017 at 23:13:24 UTC, Moritz Maxeiner 
> wrote:
>> On Sunday, 27 August 2017 at 19:47:59 UTC, Alex wrote:
>>> [...]
>>
>> To expand on the earlier workaround: You can also adapt a 
>> floating point to string algorithm in order to dynamically 
>> determine an upper bound on the number of after decimal point 
>> digits required. Below is an untested adaption of the 
>> reference C implementation of errol0[1] for that purpose (MIT 
>> license as that is what the original code is under):
>>
>> [...]
>
> Hey, cool!
> Thanks for the efforts :)

No problem, two corrections to myself, though:
1) It's a lower bound, not an upper bound (you need at least that 
many digits in order to not lose precision)
2) The code is missing `_ > ulong.min` checks along the existing 
`_ < ulong.max` checks


More information about the Digitalmars-d-learn mailing list