Floating point rounding modes: we should restrict them slightly

bearophile bearophileHUGS at lycos.com
Sun Sep 13 16:14:27 PDT 2009


Walter Bright:

> Don:
> > PROPOSAL:
> > Change the spec by adding the line to float.html:
> > "If the floating-point rounding mode is changed within a function, it 
> > must be restored before the function exits. If this rule is violated 
> > (for example, by the use of inline asm), the rounding mode used for 
> > subsequent calculations is undefined."
> 
> I added it into float.html for D2.

An important purpose of a not bug-prone language is remove as many undefined situations as possible. If you add that to D2 specs, can the compiler catch at compile time all cases of violations to that rule?

D has something for the actions that must be done before the function exits, the scope(exit). Can something like that be used to automatically avoid undefined rounding situations?

Bye,
bearophile



More information about the Digitalmars-d mailing list