Re: [BLACKBOX] INTEGER Add Has Wrong result?

From: [at]} <Chris>
Date: Thu, 7 Apr 2011 08:33:50 +0930

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

>-----Original Message-----
>From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
>luowy{([at]})nowhere.xy
>Sent: Thursday, 7 April 2011 7:55 AM
>To: BLACKBOX{([at]})nowhere.xy
>Subject: [BLACKBOX] INTEGER Add Has Wrong result
>
>look it:
>
> VAR i,j:INTEGER;l:LONGINT;
> BEGIN
> i:=MAX(INTEGER);(* 07FFFFFFH *)
> j:=1;
> l:=i+j;(* l should be 080000000L *)
> StdLog.Int(l);Log.Ln; (* ???? l:= -2147483648;

The compiler is doing what you have told it to do i.e. add two integers
together; store the result in a longint. If you want the result to be
080000000L instead you should change the last two lines to:

  l:=LONG(i)+j;
  StdLog.Int(l);StdLog.Ln;

Regards,
Chris Burrows
CFB Software

Astrobe v3.3: ARM Oberon-07 Development System
http://www.astrobe.com


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-903506249_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwID4tLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLVxw
YXINCj5G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0ZCIFNvZnR3YXJlXHBhcg0KXHBhcg0KQXN0cm9iZSB2My4zOiBBUk0gT2Jlcm9uLTA3
IERldmVsb3BtZW50IFN5c3RlbVxwYXINCmh0dHA6Ly93d3cuYXN0cm9iZS5jb21ccGFyDQpccGFy
DQpccGFyDQotLS0tXHBhcg0KVG8gdW5zdWJzY3JpYmUsIHNlbmQgYSBtZXNzYWdlIHdpdGggYm9k
eSAiU0lHTk9GRiBCTEFDS0JPWCIgdG8gTElTVFNFUlZATElTVFMuT0JFUk9OLkNIXH19AAAAPw==
----boundary-LibPST-iamunique-903506249_-_---
Received on Thu Apr 07 2011 - 01:03:50 UTC

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