- BYTE arithmetic

From: [at]} <Wojtek>
Date: Thu, 22 Jun 2006 10:38:31 -0400 (EDT)

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


The bottom line: use INTEGER as a loop counter. Do not use BYTE
or SHORTINT.

VAR
b : BYTE; i: INTEGER;
 i := b;
 FOR i := 0 TO MAX(BYTE) DO



On Thu, 22 Jun 2006, Treutwein Bernhard wrote:

> Hi Rex,
>
> [...]
> > >Beware also that the following loops for ever:
> > >
> > >VAR
> > > b : BYTE;
> > >FOR b := 0 TO MAX(BYTE) DO

> >
> > This seems to me like an error in the language
> > specification, but in any case it can be trapped by integer
> > overflow checking, which can be implemented with compiler option '+'.
> >
>
> when I encountered it (years ago), there was no hint
> about how to enable overflow checking ...
>
> The point is: INC(b) returns BYTE as opposed
> to b := b + 1 which produces a compiler error since

> b + 1 is INTEGER. In the latter case you have to explicitely
> use SHORT(SHORT(b+1)) to get it to compile.
>
> At least the possible (silent? by default) loss of digits is
> labeled in the latter case.
>
> regards
> --
> Bernhard Treutwein, IuK, Ref. III A 3
> Bernhard.Treutwein(at)verwaltung uni-muenchen de

--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy



----boundary-LibPST-iamunique-2086000814_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwI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oZSBwb2ludCBpczogSU5DKGIpIHJldHVybnMgQllURSBhcyBv
cHBvc2VkXHBhcg0KPiB0byBiIDo9IGIgKyAxIHdoaWNoIHByb2R1Y2VzIGEgY29tcGlsZXIgZXJy
b3Igc2luY2VccGFyDQo+IGIgKyAxIGlzIElOVEVHRVIuIEluIHRoZSBsYXR0ZXIgY2FzZSB5b3Ug
aGF2ZSB0byBleHBsaWNpdGVseVxwYXINCj4gdXNlIFNIT1JUKFNIT1JUKGIrMSkpIHRvIGdldCBp
dCB0byBjb21waWxlLlxwYXINCj5ccGFyDQo+IEF0IGxlYXN0IHRoZSBwb3NzaWJsZSAoc2lsZW50
PyBieSBkZWZhdWx0KSBsb3NzIG9mIGRpZ2l0cyBpc1xwYXINCj4gbGFiZWxlZCBpbiB0aGUgbGF0
dGVyIGNhc2UuXHBhcg0KPlxwYXINCj4gcmVnYXJkc1xwYXINCj4gLS1ccGFyDQo+IFx0YWIgQmVy
bmhhcmQgVHJldXR3ZWluLCBJdUssIFJlZi4gSUlJIEEgM1xwYXINCj4gXHRhYiBCZXJuaGFyZC5U
cmV1dHdlaW4oYXQpdmVyd2FsdHVuZyB1bmktbXVlbmNoZW4gZGVccGFyDQpccGFyDQotLS0gQmxh
Y2tCb3hccGFyDQotLS0gc2VuZCBzdWJqZWN0IEhFTFAgb3IgVU5TVUJTQ1JJQkUgdG8gYmxhY2ti
b3hAb2Jlcm9uLmNofX0AZXYEkCxFL0P3Lg==


----boundary-LibPST-iamunique-2086000814_-_---
Received on Thu Jun 22 2006 - 16:38:31 UTC

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