Floating-point Modulus math.fmod

Fendercaster via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 7 08:02:18 PST 2016


On Monday, 7 November 2016 at 09:21:11 UTC, Ilya Yaroshenko wrote:
> On Sunday, 6 November 2016 at 21:45:28 UTC, Fendercaster wrote:
>> I'm not quite sure if this is the right forum to ask this 
>> question:
>> I've been trying to implement the "floating-point modulus" 
>> function from the math library. Equivalently that's what I've 
>> tried in Python too. Problem is - the results are different 
>> and not even close. Please have a look at both snippets. Maybe 
>> someone can help me out:
>>
>> [...]
>
> Python uses 64-bit doubles. You may want to try with `double` 
> and `core.stdc.tgmath` -- Ilya

I'll give it a shot. Since the "real" type usually considers 
80-bit operands, is the D variant more precise? And which of 
those two results is correct, if any?


More information about the Digitalmars-d-learn mailing list