Differences in results when using the same function in CTFE and Runtime

user1234 user1234 at 12.de
Thu Aug 8 13:31:43 UTC 2024


On Thursday, 8 August 2024 at 10:31:32 UTC, Carsten Schlote wrote:
> Hi
>
> [...]
>
> I can imagine that bugs causes by such subtil differences might 
> be very difficult to fix.
>
>
> Any experiences or thought on this?
>
> Greetz
> Carsten

During CTFE _there has to be_ much more round-trips between the 
storage and the effective operations whereas with native code 
several operations can happen without leaving the FPU... those 
are done with a different accurary (80 bits). During the round 
trips implied by CTFE you have a floating point truncation after 
each op.

You see during CTFE just `a + b * c` means two truncations, one 
after the multiply, the second after the addition (even if this 
example is not very good as those op are done using SSE)

That being said, that'd be intersting to verify if it's the 
problem. Maybe update your code to use `real` variables and let's 
see.


More information about the Digitalmars-d mailing list