axiom-developer
[Top][All Lists]
Advanced

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

RE: [Axiom-developer] Compiler coercion and DoubleFloat


From: Vanuxem Grégory
Subject: RE: [Axiom-developer] Compiler coercion and DoubleFloat
Date: Tue, 28 Feb 2006 00:05:07 +0100

Hi,

Le dimanche 26 février 2006 à 20:50 -0500, Bill Page a écrit :
> On February 26, 2006 11:45 AM Vanuxem Grégory wrote:
> > 
> > Is it possible to avoid this compiler coercion ?
> > 
> > The code is:
> >         R ==> DoubleFloat
> >         two4: R := 24.0
> >         fourty: R := 40.0::R
> >         exp40: R := 235385266837019985.41::R
> > 
> 
> It is not necessary to write this as a coercion. Try
> 
>   float(23538526683701998541,-2,10)$DoubleFloat
> 
> 'float' is the function defined in the domain DoubleFloat
> that is analogous to the one in Float.

Thanks Bill but after some searches i have found exactly 
what i'm looking for.

In fact, the parser, when it encounters a real number,
returns integer part, fractional part, length of fractional part
and exponent and call MAKE-FLOAT. MAKE-FLOAT returns mantissa,
exponent (in base 10) and a "property" attached |:BF:| 
(for big float) if $useBFasDefault is true (its default value).
postBigFloat will return, later, 
((|elt| (|Float|) |float|) 23538526683701998541 -2 10)

But if $useBFasDefault is false MAKE-FLOAT returns a lisp double-float.

So i add, at the beginning of the code

)boot $useBFasDefault:=false

the code is:
         two4: R := 24.0
         fourty: R := 40.0
         exp40: R := 235385266837019985.41

and the compiler output is:

(SEQ (LET (|:| |two4| (|DoubleFloat|)) 24.0)
     (LET (|:| |fourty| (|DoubleFloat|)) 40.0)
     (LET (|:| |exp40| (|DoubleFloat|)) 2.3538526683702E17)


Cheers,

Greg






reply via email to

[Prev in Thread] Current Thread [Next in Thread]