Floating point rounding modes: we should restrict them slightly

Rainer Deyke rainerd at eldwood.com
Wed Sep 16 14:40:08 PDT 2009


Don wrote:
> Ah. The important thing that makes this work is that the global FP state
> has a clearly defined default. (round-to-nearest, full precision, no
> floating point exceptions enabled). Part of the implicit contract of
> calling a 'memoisable pure' function is that the global FP state is in
> the default state.

Then I'm not sure it makes to treat "memoisable" as a property of a
(pure) function.  It seems more like a property of the context from
which the function is called.  *All* pure function are memoisable if you
always call them with the floating point rounding mode set to the
default.  Conversely, all pure functions can be called with an arbitrary
rounding mode if you treat them an unmemoisable.

Some function - those that don't perform any floating point calculation,
directly or indirectly - are independent from floating point state, and
could even memoised even when called with an arbitrary floating point
state.  But there is no good way to automatically detect these functions.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list