Re: [BLACKBOX] CONSTant expressions

From: [at]} <CFB>
Date: Wed, 30 Jan 2008 17:18:38 +1030

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

> -----Original Message-----
> From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
> Campbell, Robert D (SELEX) (UK Edinburgh)
> Sent: Thursday, 17 January 2008 10:23 PM
> To: BLACKBOX{([at]})nowhere.xy
> Subject: [BLACKBOX] CONSTant expressions
>
> Folks
>
> This is not the most important problem ever, but
> the list has been fairly quiet recently ...
>

> I think that the compiler is overly strict in forbidding:
>
> CONST
> a = 1.;
> b = 1.;
> c = 2.;
> d = c / (a - b);
>
>
> In a language that supports INF why is division by 0
> SOMETIMES forbidden?
>

As I'm currently experimenting with the compiler I just had a closer look at
why this is happening. You will find the relevant code in the file Procedure

DevCPB.DivConst.

If you replace the statement:

  IF y.realval # 0.0 THEN
  ...
  ...
  ELSE z.realval := err(205)

with

  IF y.realval # 0.0 THEN
  ...
  ...
  ELSE z.realval := DevCPM.InfReal

and recompile DevCPB then your example code compiles OK and returns the
result INF for 'd'.

However, a comprehensive fix is unlikely to be as simple as that. e.g.
should it also check that x.realval # 0.0 to handle the case of 0. / 0. ?

Anyway, the logic of the procedure is quite readable. It should give you a
better insight into how BB is behaving. Knowing the error codes is useful
when reading / identifying these functions. They are listed in
Dev\Rsrc\Errors.odc

Regards,
Chris

Chris Burrows
CFB Software
http://www.cfbsoftware.com/cp


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-2102136142_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0M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gb2YgdGhl
IHByb2NlZHVyZSBpcyBxdWl0ZSByZWFkYWJsZS4gSXQgc2hvdWxkIGdpdmUgeW91IGFccGFyDQpi
ZXR0ZXIgaW5zaWdodCBpbnRvIGhvdyBCQiBpcyBiZWhhdmluZy4gS25vd2luZyB0aGUgZXJyb3Ig
Y29kZXMgaXMgdXNlZnVsXHBhcg0Kd2hlbiByZWFkaW5nIC8gaWRlbnRpZnlpbmcgdGhlc2UgZnVu
Y3Rpb25zLiBUaGV5IGFyZSBsaXN0ZWQgaW5ccGFyDQpEZXZcXFJzcmNcXEVycm9ycy5vZGNccGFy
DQpccGFyDQpSZWdhcmRzLFxwYXINCkNocmlzXHBhcg0KXHBhcg0KQ2hyaXMgQnVycm93c1xwYXIN
CkNGQiBTb2Z0d2FyZVxwYXINCmh0dHA6Ly93d3cuY2Zic29mdHdhcmUuY29tL2NwXHBhcg0KXHBh
cg0KXHBhcg0KLS0tLVxwYXINClRvIHVuc3Vic2NyaWJlLCBzZW5kIGEgbWVzc2FnZSB3aXRoIGJv
ZHkgIlNJR05PRkYgQkxBQ0tCT1giIHRvIExJU1RTRVJWQExJU1RTLk9CRVJPTi5DSFx9fQAgdW4=
----boundary-LibPST-iamunique-2102136142_-_---
Received on Wed Jan 30 2008 - 07:48:38 UTC

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