(unknown charset) Re: [BLACKBOX] CONSTant expressions

From: (unknown charset) [at]} <Robert>
Date: Sun, 20 Jan 2008 12:45:46 +0000

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

CFB Software wrote:
> Three different systems, three different results! Remember - you are using
> software designed by computer scientists on hardware designed by electronic
> engineers. Whatever makes you think they should behave like mathematicians

No, no, NO! We are NOT talking Mathematics, we are talking Numerical Analysis,
a (much neglected but important) branch of Computer Science.


Josef Templ wrote:
> Also the IEEE Std is not mentioned in the BB docu, so it does not claim to
> be compliant.

Yes it is, do an Info->Search in Docu for 'IEEE'. The 'Format' is mentioned
several times. 'Standard' is mentioned at least once. The Math Module gives
extensive support. The hardware we all own and use is fully IEEE compliant.

BlackBox does not claim to be 'fully IEEE compliant', whatever that might mean.
Standards (I particularly remember RS-232) give options. Different RS-232
compliant devices chose different options, so were not interoperable.

BlackBox implements a subset of the IEEE options, apparently correctly with
variables. One IEEE option is whether divide by 0 causes an interrupt. The
variable arithmetic is consistent with this option being OFF, the constant
arithmetic is consistent with this option being ON. Not helpful!. Constant
multiplication by 0 looses the sign bit. This differs from variable arithmetic,
and is not consistent with any IEEE option. Even less helpful!

Does any of this matter? Not often. But is is a ticking timebomb. I think it
undermines the reliability of the language. Sooner of later if will trip
someone up, with who knows what consequences. Early (Oberon-F) licenses used to
say it should not be used for safety related applications. The current freeware
license says (I am NOT a lawyer) that users are responsible for how they use it.
That is fine, but users need to understand what they have.

I recommend the paper "How Java’s Floating-Point Hurts Everyone Everywhere"
http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf

I think that BlackBox suffers the problems described, but to a lesser extent.

For example FULL IEEE compliance requires the ability to set directed rounding
modes at run-time. Java forbids this. It is not obvious how to do this in
BlackBox, but see below. (But please use these routines with care!)


CFB Software wrote:
 >> OutBool ('pi = Pi ? ', pi = Math.Pi ()); (* FALSE *)
> I would have expected the third result to be TRUE - have I fallen into a
> carefully-laid trap?

The IEEE hardware works to 80 bit precision, and gives options to round
final and intermediate results to 32 bits or 64 bits. BlackBox chooses to
round intermediate results to 80 bits (for improved accuracy), only rounding
to 64 bits when REAL numbers are stored into a 64 bit memory location. The
call Math.Pi () leaves an 80-bit result in the floating point register, that
is then compared with a 64-bit rounded version. Result? they are different!
Personally I think this is a generally good decision.


The c standard REQUIRES that intermediate results are rounded to lower precision
(see page 11 of "Miscalculating Area and Angles of a Needle-like Triangle"
http://www.cs.berkeley.edu/~wkahan/Triangle.pdf).
I guess that C# follows c's lead and unnecessarily rounds the result of its Pi
function.


Regards

Robert



Below: how to set/read the FPU control register, and some useful options.


PROCEDURE [code] GetMode (VAR n : SHORTINT)
   0D9H, 038H; (* FSTCW -> n *)

PROCEDURE [code] SetMode (VAR flgs : SET)
   0D9H, 028H; (* flgs -> FLDCW *)

BEGIN
   bBoxDef := {1..6, 8, 9};
   rndDn := {0..6, 8, 9, 10};
   rndUp := {0..6, 8, 9, 11};
   rndDn := {0..6, 10}; (* Single precision *)
   rndUp := {0..6, 11}; (* Single precision *)
   quiet := {0..6, 8, 9};


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-320591031_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzc1xmY2hhcnNldDAgQXJpYWw7fQ0Ke1xmMVxmbW9kZXJuIENvdXJpZXIgTmV3O30NCntcZjJc
Zm5pbFxmY2hhcnNldDIgU3ltYm9sO30NCntcZjNcZm1vZGVyblxmY2hhcnNldDAgQ291cmllciBO
ZXc7fX0NCntcY29sb3J0YmxccmVkMFxncmVlbjBcYmx1ZTA7XHJlZDBcZ3JlZW4wXGJsdWUyNTU7
fQ0KXHVjMVxwYXJkXHBsYWluXGRlZnRhYjM2MCBcZjBcZnMyMCBDRkIgU29mdHdhcmUgd3J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D
VyAgKilccGFyDQpccGFyDQpCRUdJTlxwYXINCiAgIGJCb3hEZWYgIDo9ICBcezEuLjYsIDgsIDlc
fTtccGFyDQogICBybmREbiAgICA6PSAgXHswLi42LCA4LCA5LCAxMFx9O1xwYXINCiAgIHJuZFVw
ICAgIDo9ICBcezAuLjYsIDgsIDksIDExXH07XHBhcg0KICAgcm5kRG4gICAgOj0gIFx7MC4uNiwg
MTBcfTtcdGFiICgqICBTaW5nbGUgcHJlY2lzaW9uICAqKVxwYXINCiAgIHJuZFVwICAgIDo9ICBc
ezAuLjYsIDExXH07XHRhYiAoKiAgU2luZ2xlIHByZWNpc2lvbiAgKilccGFyDQogICBxdWlldCAg
ICA6PSAgXHswLi42LCA4LCA5XH07XHBhcg0KXHBhcg0KXHBhcg0KLS0tLVxwYXINClRvIHVuc3Vi
c2NyaWJlLCBzZW5kIGEgbWVzc2FnZSB3aXRoIGJvZHkgIlNJR05PRkYgQkxBQ0tCT1giIHRvIExJ
U1RTRVJWQExJU1RTLk9CRVJPTi5DSH19ACBjb24
----boundary-LibPST-iamunique-320591031_-_---
Received on Sun Jan 20 2008 - 13:45:46 UTC

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