gm2
[Top][All Lists]
Advanced

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

Re: [Gm2] Are there standard functions such as FLOAT and TRUNC?


From: Fischlin Andreas
Subject: Re: [Gm2] Are there standard functions such as FLOAT and TRUNC?
Date: Wed, 17 Feb 2010 23:17:49 +0100

Dear all,

I recommend to use assignment compatibility if you wish to convert among reals of different precision. This means:

VAR
        rs: SHORTREAL;
        r: REAL;
        rl: LONGREAL;

  rs := r;    rs := rl;
  r :=  rs;   r := rl;
  rl := rs;  rl := r;

All of above assignment statements should be legal and do the job you want. Any other solution trying to convert in the middle of an expression would be implementation dependent. For that reason we use in our RAMSES (http://www.sysecol.ethz.ch/SimSoftware/RAMSES/) code throughout the assignment technique.

Regards,
Andreas



ETH Zurich
Prof. Dr. Andreas Fischlin
Systems Ecology - Institute of Integrative Biology
CHN E 21.1
Universitaetstrasse 16
8092 Zurich
SWITZERLAND

address@hidden
www.sysecol.ethz.ch

+41 44 633-6090 phone
+41 44 633-1136 fax

Make it as simple as possible, but distrust it!
________________________________________________________________________

On 17/Feb/2010, at 21:14 , Carl Glassberg wrote:

Hello, again.

Are there standard functions such as FLOAT and TRUNC for conversion to/from SHORTREAL/REAL/LONGREAL?

If not, can VAL(LONGREAL, ...) and so forth be used?

I am planning to test SHORTREAL/REAL/LONGREAL.

So far, this is what gm2 versions of Machar yield as machine constants for floating-point:

(Created by converting machar.c to three gm2 versions, one each for
SHORTREAL, REAL, LONGREAL)
--------------------------------------------------------------
(* SHORTREAL = float *)
ibeta =           2
it =              24
irnd =            5
ngrd =            0
machep =         -23
negep =          -24
iexp =            8
minexp =         -126
maxexp =          128
eps =   0.1192092E-6
epsneg =   0.5960464E-7
xmin =  0.1175494E-37
xmax =  3.4028234E+38
---------------------------------------
(* REAL = double *)
ibeta =           2
it =             53
irnd =            5
ngrd =            0
machep =        -52
negep =         -53
iexp =           11
minexp =        -1022
maxexp =         1024
eps =   0.222044604925031E-15
epsneg =   0.111022302462515E-15
xmin =  0.222507385850720E-307
xmax =  1.797693134862315E+308
-----------------------------------------------
(* LONGREAL = long double *)
ibeta =         2
it =            64
irnd =          5
ngrd =          0
machep =       -63
negep =        -64
iexp =          15
minexp =       -16382
maxexp =        16384
eps =    0.108420217248550443E-18
epsneg =    0.542101086242752217E-19
xmin =  0.336210314311209350E-4931
xmax =  1.189731495357231764E+4932
----------------------------------------------------

Carl







_______________________________________________
gm2 mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/gm2





reply via email to

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