Discussion:
where is double precision INFINITY and NAN defined?
(too old to reply)
m***@gmail.com
2016-07-29 04:43:38 UTC
Permalink
Raw Message
I am using the ADW modula2 compiler (formerly stony brook compler), and I can't find a DEF file that has the CONST values for NaN and Infinity in IEEE double precision floating point.

Not sure how to make a 64-bit floating point constant, although maybe I can try using the CAST operator on the known values....

any help is appreciated.

e
m***@gmail.com
2016-07-29 04:51:17 UTC
Permalink
Raw Message
i Just tried the following, it won't compile:

CONST
INFINITY = CAST(REAL64, 7FF0000000000000H);
NINFINITY = CAST(REAL64, FFF0000000000000H);

compiler says illegal type cast... bummer... how can I get these magic values into a constant?
m***@gmail.com
2016-07-29 05:06:56 UTC
Permalink
Raw Message
I suppose in a pinch i could write an assembler module and make an external symbol. but that would make it a variable, which i could do myself through a type cast. how unfortunate i can't coernce the CARDINAL64 into a real64, the cast system won't let me do that.
Nemo
2016-07-29 18:20:56 UTC
Permalink
Raw Message
Post by m***@gmail.com
CONST
INFINITY = CAST(REAL64, 7FF0000000000000H);
NINFINITY = CAST(REAL64, FFF0000000000000H);
compiler says illegal type cast... bummer... how can I get these magic values into a constant?
I do not use ADW but VAL() or LFLOAT() should work.
Rainard Buchmann
2016-07-31 12:38:49 UTC
Permalink
Raw Message
Post by m***@gmail.com
CONST
INFINITY = CAST(REAL64, 7FF0000000000000H);
NINFINITY = CAST(REAL64, FFF0000000000000H);
compiler says illegal type cast... bummer... how can I get these magic
values into a constant?
In ADW-Modula-2 you may use :

CONST
INFINITY = VAL (LONGREAL, 7FF0000000000000H) ;
NINFINITY = VAL (LONGREAL, 0FFF0000000000000H) ;
Rainard Buchmann
2016-07-31 12:33:40 UTC
Permalink
Raw Message
Post by m***@gmail.com
CONST
INFINITY = CAST(REAL64, 7FF0000000000000H);
NINFINITY = CAST(REAL64, FFF0000000000000H);
compiler says illegal type cast... bummer... how can I get these magic
values into a constant?
in ADW-Modula-2 you may use :

CONST
INFINITY = VAL (LONGREAL, 7FF0000000000000H) ;
NINFINITY = VAL (LONGREAL, 0FFF0000000000000H) ;
m***@gmail.com
2016-08-22 06:54:40 UTC
Permalink
Raw Message
Thanks for the tip, it turns out there is a slight quirk, almost a bug, where if you define a type like
TYPE REAL64 = LONGREAL

then try to do the cast to a REAL64 it won't work... it only allows raw casting to low level primitive types, not an alias to the same type... I don't know why i liked the name REAL64 better than longreal, but hey that is easy to fix!

now if only i could get a clean ISO library for RealtoStr that doesn't introduce rounding errors, i should be all set.
Martin Brown
2016-08-22 08:54:05 UTC
Permalink
Raw Message
Post by m***@gmail.com
now if only i could get a clean ISO library for RealtoStr that doesn't introduce rounding errors, i should be all set.
In what sense does ISO RealToStr introduce rounding errors?

I recall an FP bug back in prehistory where under certain circumstances
the behaviour of TRUNC could be subverted by the FPU rounding settings
being non-standard in the Logitech M2 OS/2 compiler.

This first showed in floating point numbers drifting upwards by 1lsb of
display with each data refresh when a GUI was being used.

Perhaps if you posted the offending code it might be possible to check
it on other compilers.
--
Regards,
Martin Brown
Loading...