----boundary-LibPST-iamunique-951144845_-_-
Content-type: text/plain
I haven't done any experiments, but a possible
explanation is that the FPU operates at 80 bits
floating point precision, only rounding to 64
when the number needs to be stored in memory,
rather than just being left on the FPU stack.
I guess that 1.000000000000000001 is non-unity
as an 80-bit IEEE number, but rounds to 1 when
stored as a 64-bit IEEE number.
As an example try x := Math.Pi()
then later try
x = Math.Pi(). The answer is FALSE.
Cheers
Robert
> Hello:
>
> the following code illustrates a numeric problem with CP
> compiler, version BlackBox 1.4 unpatched. The comparison
> yields either TRUE or FALSE depending on the precision
> of the REAL number. (Try exchanging the order of the
> lines where the REAL variable is assigned). The language
> report does not say anything about such a mixed comparison
> (realVar = intVar). In the spirit of robustness I would
> rather prefer that this expression does not compile at all.
> ENTIER should be necessary, rather than relying on
> rounding the REAL variable in some implicit way.
>
> Excuse me if this was already patched.
>
> Wojtek Skulski skulski{([at]})nowhere.xy>
> MODULE TestEqual;
> IMPORT StdLog;
> PROCEDURE Test*;
> VAR
> tst: BOOLEAN;
> r: REAL; long: LONGINT; int: INTEGER;
> BEGIN
> long := 1; int := 1;
> r := 1.000000000000000001; (* TRUE*)
> r := 1.0000000000001; (* FALSE*)
> tst := (r = long);
> StdLog.String("Real = long: ");
> StdLog.Bool (tst); StdLog.Ln;
> tst := (r = int);
> StdLog.String("Real = int: ");
> StdLog.Bool (tst); StdLog.Ln;
> END Test;
> END TestEqual.
>
> TestEqual.Test
--------------------------------------------
To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
blackbox-request{([at]})nowhere.xy
To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.
Send any problem reports or questions related to this email list to the list owner at
owner-blackbox{([at]})nowhere.xy
Current posting policy:
a) To post you should use the same address by which you are subscribed to the mailing list. That way, the list server will recognize you as subscriber and forward your posting immediately, without creating any overhead.
b) If, for some reason, you cannot post from the address, by which you are subscribed, your message will be moderated to avoid spam. Please understand that moderation will often cause some delay, in particular over weekends or holydays.
----boundary-LibPST-iamunique-951144845_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIEkgaGF2ZW4ndCBkb25lIGFueSBleHBlcmltZW50
cywgYnV0IGEgcG9zc2libGVccGFyDQpleHBsYW5hdGlvbiBpcyB0aGF0IHRoZSBGUFUgb3BlcmF0
ZXMgYXQgODAgYml0c1xwYXINCmZsb2F0aW5nIHBvaW50IHByZWNpc2lvbiwgb25seSByb3VuZGlu
ZyB0byA2NFxwYXINCndoZW4gdGhlIG51bWJlciBuZWVkcyB0byBiZSBzdG9yZWQgaW4gbWVtb3J5
LFxwYXINCnJhdGhlciB0aGFuIGp1c3QgYmVpbmcgbGVmdCBvbiB0aGUgRlBVIHN0YWNrLlxwYXIN
ClxwYXINCkkgZ3Vlc3MgdGhhdCAxLjAwMDAwMDAwMDAwMDAwMDAwMSBpcyBub24tdW5pdHlccGFy
DQphcyBhbiA4MC1iaXQgSUVFRSBudW1iZXIsIGJ1dCByb3VuZHMgdG8gMSB3aGVuXHBhcg0Kc3Rv
cmVkIGFzIGEgNjQtYml0IElFRUUgbnVtYmVyLlxwYXINClxwYXINCkFzIGFuIGV4YW1wbGUgdHJ5
ICB4IDo9ICBNYXRoLlBpKClccGFyDQpccGFyDQp0aGVuIGxhdGVyIHRyeVxwYXINClxwYXINCngg
PSBNYX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