Re: Numeric problem in BlackBox 1.4

From: Dominik Gruntz <"Dominik>
Date: Mon, 17 Feb 2003 22:56:24 +0100

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

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

>
> I think that these two answers neatly illustrate the confusion.
> Dominik, who is definitely a better expert than I am, expects
> both cases to be consistent.
oops, you misunderstood me. I was referring to the two cases
    tst := (r = long);
and
    tst := (r = int);
which both should return the same result.

I am very cautious with *any* expectations regarding floating point
expressions. Another example? Here is one:

    VAR x, y: REAL;
    x := 9007199254740993;
    y := 9007199254740994;
    StdLog.Real(y - x);

> I repeat my question. Is this confusion warranted, or should rather
> the implementation of the compiler be tightened up such that an
> explicit type cast would be required for the relations. In other words,
> the relation (realVar = intVar) would not compile? Is this a sensible
> solution, or should it rather be left open for implementers?
so, after you solved the above example, you will also argue, that
the assignment of integers to real variables should also be prohibited,
and we are back to Modula-2.

But in your example the problem is not the comparison between
two reals, because this comparison is performed exactly, without
any rounding problems! The point is, that 1.000000000000000001
cannot be represented exactly in 64bits (similarly to the real number
0.1, which also cannot represented exactly in 64 bits).

Probably the easiest would be, to drop floats all together......

- Dominik


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

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


----boundary-LibPST-iamunique-445470869_-_---
Received on Mon Feb 17 2003 - 22:56:24 UTC

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