[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CLTL compatible type contagion?



>>>>> "Raymond" == Raymond Toy <toy@rtp.ericsson.se> writes:

Raymond> I presume that clisp does the addition in
Raymond> double-float and then coerces the result to single-float,
Raymond> causing the overflow.

Raymond> This behavior makes numerical work more difficult than it
Raymond> should be.

Others may disagree.  :-)

Raymond> Does anyone know where the routines are that cause this
Raymond> behavior?  I'd like to change it in my own copy of clisp.  I
Raymond> tried looking through the source, but I don't read German.

Well, you could take a look at flo_rest.d, and specifically, the GEN_F_op2
macro.  Look at the end of the "RETURN CONCAT" lines, where you see
identifiers like FF_to_SF, DF_to_SF ..  You could change these
to FF_to_SF_, DF_to_SF_, etc.  And immediately above have a
conditional like :

#ifdef CONTAGION_HACK
#define FF_to_SF_(x) x
#define DF_to_SF_(x) x
#define LF_to_SF_(x) x
#define DF_to_FF_(x) x
#define LF_to_FF_(x) x
#define LF_to_DF_(x) x
#else
#define FF_to_SF_(x) FF_to_SF(x)
#define DF_to_SF_(x) DF_to_SF(x)
#define LF_to_SF_(x) LF_to_SF(x)
#define DF_to_FF_(x) DF_to_FF(x)
#define LF_to_FF_(x) LF_to_FF(x)
#define LF_to_DF_(x) LF_to_DF(x)
#endif

This hack just addresses your particular example, though.

Personally, I like being reminded by CLISP about such careless behavior.