Re: Numeric problem in BlackBox 1.4

From: Dominik Gruntz <"Dominik>
Date: Sun, 16 Feb 2003 13:26:11 +0100

----boundary-LibPST-iamunique-499655605_-_-
Content-type: text/plain

> rather than relying on rounding the REAL variable in some implicit way.
The REAL variable is not rounded in any way, but rather the int (or long)
is converted to a REAL, in this example without loss of precision (as the
integer 1 can be represented exactly as REAL).

The comparison is then performed between two real numbers, and I would
expect that the tests both either return true or false.

- Dominik


----- Original Message -----
From: "Wojtek Skulski" <skulski{([at]})nowhere.xy
To: <support{([at]})nowhere.xy
Cc: "Wojtek Skulski" <skulski{([at]})nowhere.xy
Sent: Sunday, February 16, 2003 4:52 AM
Subject: Numeric problem in BlackBox 1.4


> 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.
>
>


--------------------------------------------

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-499655605_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwID4gcmF0aGVyIHRoYW4gcmVseWluZyBvbiByb3Vu
ZGluZyB0aGUgUkVBTCB2YXJpYWJsZSBpbiBzb21lIGltcGxpY2l0IHdheS5ccGFyDQpUaGUgUkVB
TCB2YXJpYWJsZSBpcyBub3Qgcm91bmRlZCBpbiBhbnkgd2F5LCBidXQgcmF0a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vbWUgZGVsYXksIGlu
IHBhcnRpY3VsYXIgb3ZlciB3ZWVrZW5kcyBvciBob2x5ZGF5cy5ccGFyDQp9


----boundary-LibPST-iamunique-499655605_-_---
Received on Sun Feb 16 2003 - 13:26:11 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:29:27 UTC