Hi all, One of the gotcha's I encountered while trying to improve Texts.WriteRealFix was that in PO the standard function procedure FLOOR overflows for values > 16777215.00 (2^24-1) and not, as I expected, only for values > 2147483647.00 (2^31-1). I guess I'm not the only one who is surprised by this (see for instance: https://lists.inf.ethz.ch/pipermail/oberon/2020/015013.html). Some other Oberon-07 compilers (e.g. OBNC) do not have this limit. For FLT I can understand the limit of 16777215 because larger integers do not always have an exact floating point representation. For FLOOR there is no parallel argument: every REAL up to 2147483647.00 can unequivocally be transferred to a 32-bit INTEGER. So why this limit? Does anyone have an opinion on this? If you would like to test these limits, you can use procedure TestRealIO.FltFloor which can be found here: https://github.com/hansklav/Oberon-REAL-IO/blob/main/TestRealIO.Mod Regards, Hans Klaver
Hi The limit of 2^24-1 makes somehow sense as you normally expect FLOOR(FLT(x)) = x As the mantissa of a REAL is only 24 bits, all REALs larger than 2^24 are not exact: As r := 2000000000.0 and r := 2000000189.0 have the same binary representation, FLOOR would return to all REALs in between the same value. br Jörg Von: Oberon <oberon-bounces@lists.inf.ethz.ch> im Auftrag von Hans Klaver <hklaver@dds.nl> Datum: Montag, 16. Januar 2023 um 13:13 An: ETH Oberon and related systems <oberon@lists.inf.ethz.ch> Betreff: [Oberon] Upper limit of FLOOR Hi all, One of the gotcha's I encountered while trying to improve Texts.WriteRealFix was that in PO the standard function procedure FLOOR overflows for values > 16777215.00 (2^24-1) and not, as I expected, only for values > 2147483647.00 (2^31-1). I guess I'm not the only one who is surprised by this (see for instance: https://lists.inf.ethz.ch/pipermail/oberon/2020/015013.html). Some other Oberon-07 compilers (e.g. OBNC) do not have this limit. For FLT I can understand the limit of 16777215 because larger integers do not always have an exact floating point representation. For FLOOR there is no parallel argument: every REAL up to 2147483647.00 can unequivocally be transferred to a 32-bit INTEGER. So why this limit? Does anyone have an opinion on this? If you would like to test these limits, you can use procedure TestRealIO.FltFloor which can be found here: https://github.com/hansklav/Oberon-REAL-IO/blob/main/TestRealIO.Mod Regards, Hans Klaver -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
On 16 Jan. 2023, at 14:18 joerg.straube@iaeth.ch wrote:
The limit of 2^24-1 makes somehow sense as you normally expect FLOOR(FLT(x)) = x
For reasons of symmetry and inverse operations this indeed makes sense.
As the mantissa of a REAL is only 24 bits, all REALs larger than 2^24 are not exact: As r := 2000000000.0 and r := 2000000189.0 have the same binary representation, FLOOR would return to all REALs in between the same value.
You are right. I did not realise that OBNC must make use of a 64-bit floating point type for REAL and a 32-bit type for INTEGER. It certainly helps to have a list ready for all these limits you have to deal with. For that I prepared Limits.Mod. Thanks, Hans
One of the gotcha's I encountered while trying to improve Texts.WriteRealFix was that in PO the standard function procedure FLOOR overflows for values > 16777215.00 (2^24-1) and not, as I expected, only for values > 2147483647.00 (2^31-1). I guess I'm not the only one who is surprised by this (see for instance: https://lists.inf.ethz.ch/pipermail/oberon/2020/015013.html).
Some other Oberon-07 compilers (e.g. OBNC) do not have this limit.
For FLT I can understand the limit of 16777215 because larger integers do not always have an exact floating point representation. For FLOOR there is no parallel argument: every REAL up to 2147483647.00 can unequivocally be transferred to a 32-bit INTEGER.
So why this limit? Does anyone have an opinion on this?
If you would like to test these limits, you can use procedure TestRealIO.FltFloor which can be found here:https://github.com/hansklav/Oberon-REAL-IO/blob/main/TestRealIO.Mod
participants (2)
-
Hans Klaver -
joerg.straube@iaeth.ch