Guy T.
2020-03-01 03:54:57 UTC
Hello all,
I'm using OBNC on MacOS configured with INTEGER and REAL of length 4.
Here is a program that is puzzling me. I would expect both REAL values to be the same after calling SYSTEM.VAL twice, but it's not the case:
MODULE toto;
IMPORT Out, SYSTEM;
VAR
i: REAL;
j: INTEGER;
k: REAL;
BEGIN
i := 123.456;
j := SYSTEM.VAL(INTEGER, i);
k := SYSTEM.VAL(REAL, j);
IF i = k THEN
Out.String("OK")
ELSE
Out.String("NOT OK!"); Out.Ln;
Out.Real(i,0); Out.String(" vs "); Out.Real(k,0)
END;
Out.Ln; Out.String("INTEGER Size: "); Out.Int(SYSTEM.SIZE(INTEGER), 0);
Out.Ln; Out.String("REAL Size: "); Out.Int(SYSTEM.SIZE(REAL), 0);
Out.Ln;
END toto.
The result I get is the following:
$ obnc toto.Mod
$ ./toto
NOT OK!
1.234560E+02 vs 1.230000E+02
INTEGER Size: 4
REAL Size: 4
Any help would be appreciated.
Cheers!
Guy T.
I'm using OBNC on MacOS configured with INTEGER and REAL of length 4.
Here is a program that is puzzling me. I would expect both REAL values to be the same after calling SYSTEM.VAL twice, but it's not the case:
MODULE toto;
IMPORT Out, SYSTEM;
VAR
i: REAL;
j: INTEGER;
k: REAL;
BEGIN
i := 123.456;
j := SYSTEM.VAL(INTEGER, i);
k := SYSTEM.VAL(REAL, j);
IF i = k THEN
Out.String("OK")
ELSE
Out.String("NOT OK!"); Out.Ln;
Out.Real(i,0); Out.String(" vs "); Out.Real(k,0)
END;
Out.Ln; Out.String("INTEGER Size: "); Out.Int(SYSTEM.SIZE(INTEGER), 0);
Out.Ln; Out.String("REAL Size: "); Out.Int(SYSTEM.SIZE(REAL), 0);
Out.Ln;
END toto.
The result I get is the following:
$ obnc toto.Mod
$ ./toto
NOT OK!
1.234560E+02 vs 1.230000E+02
INTEGER Size: 4
REAL Size: 4
Any help would be appreciated.
Cheers!
Guy T.