[Oberon] Upper limit of FLOOR

joerg.straube at iaeth.ch joerg.straube at iaeth.ch
Mon Jan 16 14:18:13 CET 2023


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.


Von: Oberon <oberon-bounces at lists.inf.ethz.ch> im Auftrag von Hans Klaver <hklaver at dds.nl>
Datum: Montag, 16. Januar 2023 um 13:13
An: ETH Oberon and related systems <oberon at 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


Hans Klaver

Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20230116/85d73380/attachment.html>

More information about the Oberon mailing list