(unknown charset) Re: [BLACKBOX] CONSTant expressions

From: (unknown charset) [at]} <Alexander>
Date: Sun, 20 Jan 2008 01:17:22 +0600

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

Hello!

  What's with this list and overquoting? Don't people know netiquette?
  http://www.faqs.org/rfcs/rfc1855.html

JT> Case 3:
JT> Surprises me: why is pi different from Math.Pi()?

JT> Case 4:
JT> The IEEE Std has +Inf, -Inf, +0, -0, and NaN besides normal numbers.
JT> It seems that -0 is not supported in constant evaluation, which is done in
JT> the compiler, not at runtime.
JT> My explanation: Mathematics has no concept of -0, only the IEEE Std has it.
JT> Ignoring -0 in constant evaluation keeps the compiler simple. It is probably
JT> not an oversight.
JT> Also the IEEE Std is not mentioned in the BB docu, so it does not claim to be
JT> compliant.
JT> With the widespread adoption of the IEEE Std in Java and C#
JT> it might however be a good idea to stick to that standard, indeed.
JT> Supporting -0 in constant evaluation would probably be fairly simple.

JT> - JT


JT> ----- Original Message -----
JT> From: "Robert" <robert.campbell_{([at]})nowhere.xy
JT> To: <BLACKBOX{([at]})nowhere.xy
JT> Sent: Friday, January 18, 2008 7:05 PM
JT> Subject: Re: [BLACKBOX] CONSTant expressions


>> Rex Couture wrote:
>>
>>>> In a language that supports INF why is division by 0
>>>> SOMETIMES forbidden?
>>
>>> Interesting. Mathematically, INF is not a number, and therefore not a reasonable value.
>>
>> I can't resist making a few points ...
>>
>> Firstly it is an odd coincidence that on the day that I chose to complain that
>> divison by zero is a 'Good' (for 'good' read 'useful' or 'convenient' as you
>> wish) thing that should be allowed another thread had links to Ada, and then to
>> SPARK, which claims that SPARK is a good thing because it prevents division by zero!
>>
>> Mathematics contains many infinities (the point at infinity is a key ingredient
>> of projective geometry, and used by many games programmers), but I know what
>> Rex means. But we are not talking about Maths, we are talking about computer
>> arithmetic, explicitly about (a subset of) the ANSI/IEEE Std 754-198 floating
>> point format.
>>
>> In this format both Infinity & Not-a-Number are supported.
>>
>> The designers of Component Pascal chose to support INF, and thus implicitly
>> division by zero. I personally find this convenient far more often than
>> inconvenient, but clearly the designers of SPARK would disagree.
>>
>> The designers of Component Pascal chose NOT to support NaN, and thus not
>> division of zero by zero (0. / 0.). I personally find this convenient far more
>> often than inconvenient, although VERY occasionally I do want NaNs.
>>
>> Rex also said that INFs are hard to use in subsequent calculations. Yes, but not
>> much harder than other numbers. Numerical analysis always requires care.
>>
>> How many people would correctly anticipate the output of the following module?
>>
>>
>> My real point is not to question the decision to allow division by zero in
>> Component Pascal, but to suggest that once the decision has been made it should
>> be implemented consistently.
>>
>> In my example module I think the first three results are correct. The forth
>> result is evidence that the Component Pascal compiler's handling of constants
>> not only gets division by zero wrong, it gets multiplication by zero wrong also.
>>
>> Cheers
>>
>> Robert
>>
>>
>> MODULE DemoRealSums;
>>
>> IMPORT Math, Out;
>>
>> PROCEDURE OutBool (IN str : ARRAY OF CHAR; flg : BOOLEAN);
>> BEGIN
>> Out.String (str);
>> IF flg THEN Out.String (' TRUE') ELSE Out.String (' FALSE') END;
>> Out.Ln
>> END OutBool;
>>
>> PROCEDURE Do*;
>> CONST
>> aCon = 5.;
>> bCon = -5.;
>> zeroCon1 = aCon * 0.;
>> zeroCon2 = bCon * 0.;
>> VAR
>> a, b, zero1, zero2, inf1, inf2, pi : REAL;
>> BEGIN
>> a := 5.;
>> b := -5.;
>>
>> zero1 := a * 0.;
>> zero2 := b * 0.;
>> OutBool ('zero1 = xero2 ? ', zero1 = zero2); (* TRUE *)
>>
>> inf1 := 1. / zero1;
>> inf2 := 1. / zero2;
>> OutBool ('inf1 = inf2 ? ', inf1 = inf2); (* FALSE *)
>>
>> pi := Math.Pi ();
>> OutBool ('pi = Pi ? ', pi = Math.Pi ()); (* FALSE *)
>>
>> zero1 := zeroCon1;
>> zero2 := zeroCon2;
>> inf1 := 1. / zero1;
>> inf2 := 1. / zero2;
>> OutBool ('inf1 = inf2 ? ', inf1 = inf2); (* TRUE *)
>> END Do;
>> END DemoRealSums.
>>
>>
>> <Q> DevDebug.Unload
>>
>> <Q> DemoRealSums.Do
>>
>>
>> ----
>> To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy


JT> ----
JT> To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy



---=====---
 Alexander


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-1087111909_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIEhlbGxvIVxwYXINClxwYXINCiAgV2hhdCdzIHdp
dGggdGhpcyBsaXN0IGFuZCBvdmVycXVvdGluZz8gRG9uJ3QgcGVvcGxlIGtub3cgbmV0aXF1ZXR0
ZT9ccGFyDQogIGh0dHA6Ly93d3cuZmFxcy5vcmcvcmZjcy9yZmMxODU1Lmh0bWxccGFyDQpccGFy
DQpKVD4gQ2FzZSAzOlxwYXINCkpUPiBTdXJwcmlzZXMgbWU6IHdoeSBpcyBwaSBkaWZmZXJlbnQg
ZnJvbSBNYXRoLlBpKCk/XHBhcg0KXHBhcg0KSlQ+IENhc2UgNDogXHBhcg0KSlQ+IFRoZSBJRUVF
IFN0ZCBoYXMgK0luZiwgLUluZiwgKzAsIC0wLCBhbmQgTmFOIGJlc2lkZXMgbm9ybWFsI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nVnLlVubG9hZFxwYXINCj4+IFxwYXINCj4+IDxRPiAgIERlbW9SZWFsU3Vtcy5Eb1xw
YXINCj4+IFxwYXINCj4+IFxwYXINCj4+IC0tLS1ccGFyDQo+PiBUbyB1bnN1YnNjcmliZSwgc2Vu
ZCBhIG1lc3NhZ2Ugd2l0aCBib2R5ICJTSUdOT0ZGIEJMQUNLQk9YIiB0byBMSVNUU0VSVkBMSVNU
Uy5PQkVST04uQ0hccGFyDQpccGFyDQpccGFyDQpKVD4gLS0tLVxwYXINCkpUPiBUbyB1bnN1YnNj
cmliZSwgc2VuZCBhIG1lc3NhZ2Ugd2l0aCBib2R5ICJTSUdOT0ZGIEJMQUNLQk9YIiB0byBMSVNU
U0VSVkBMSVNUUy5PQkVST04uQ0hccGFyDQpccGFyDQpccGFyDQpccGFyDQotLS09PT09PS0tLVxw
YXINCiBBbGV4YW5kZXJccGFyDQpccGFyDQpccGFyDQotLS0tXHBhcg0KVG8gdW5zdWJzY3JpYmUs
IHNlbmQgYSBtZXNzYWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFDS0JPWCIgdG8gTElTVFNFUlZA
TElTVFMuT0JFUk9OLkNIXHBhcg0KfQ==
----boundary-LibPST-iamunique-1087111909_-_---
Received on Sat Jan 19 2008 - 20:17:22 UTC

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