----boundary-LibPST-iamunique-549298414_-_-
Content-type: text/plain
Robert and Dominik:
testing REALs for equality is in fact advised against
in every programming textbook, precisely because of the
small differences that can get lost along the way.
The textbooks would rather suggest the test of the form
IF (ABS (real1 - real2) < epsilon) THEN
where the epsilon is a constant considered insignificant
in a given application.
How about adding an error level WARNING to either the compiler
or the DevAnalyzer which would flag f.p. data types used
with the "=" relation?
Thank you,
Wojtek Skulski skulski{([at]})nowhere.xy
On Mon, 17 Feb 2003, Dominik Gruntz wrote:
> > 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.
> >
>
> The constants defined in a Module are stored in REAL
> precision, so the above argument does not apply.
> But you are right, 1+10^(-18) is not 1 in 80 bit IEEE,
> but it is 1.0 in 64 (REAL) precision.
>
> Given the following module, the command Test.Do
> prints $FALSE.
>
> - Dominik
>
>
> MODULE Test;
>
> IMPORT StdLog, Math;
>
> PROCEDURE OnePlusTenToThePowerOfMinusEighteen(): REAL;
> BEGIN RETURN 1 + Math.IntPower(10, -18);
> END OnePlusTenToThePowerOfMinusEighteen;
>
> PROCEDURE Do*;
> VAR x: REAL;
> BEGIN
> x := OnePlusTenToThePowerOfMinusEighteen();
> StdLog.Bool(x = OnePlusTenToThePowerOfMinusEighteen());
> END Do;
>
> END 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-549298414_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIFJvYmVydCBhbmQgRG9taW5pazpccGFyDQpccGFy
DQogIHRlc3RpbmcgUkVBTHMgZm9yIGVxdWFsaXR5IGlzIGluIGZhY3QgYWR2aXNlZCBhZ2FpbnN0
XHBhcg0KaW4gZXZlcnkgcHJvZ3JhbW1pbmcgdGV4dGJvb2ssIHByZWNpc2VseSBiZWNhdXNlIG9m
IHRoZVxwYXINCnNtYWxsIGRpZmZlcmVuY2VzIHRoYXQgY2FuIGdldCBsb3N0IGFsb25nIHRoZSB3
YXkuXHBhcg0KVGhlIHRleHRib29rcyB3b3VsZCByYXRoZXIgc3VnZ2VzdCB0aGUgdGVzdCBvZiB0
aGUgZm9ybVxwYXINCklGIChBQlMgKHJlYWwxIC0gcmVhbDIpIDwgZXBzaWxvbikgVEhFTlxwYXIN
CndoZXJlIHRoZSBlcHNpbG9uIGlzIGEgY29uc3RhbnQgY29uc2lkZXJlZCBpbnNpZ25pZmljYW50
XHBhcg0KaW4gYSBnaXZlbiBhcHBsaWNhdGlvbi5ccGFyDQpccGFyDQpIb3cgYWJvdXQgYWRkaW5n
IGFuIGVycm9yIGxldmVsIFdBUk5JTkcgdG8gZWl0aGVyIHRoZSBjb21waWxlcl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