- Bit operations in Component Pascal

From: Andrew Thomas <"Andrew>
Date: Wed, 30 Mar 2005 14:45:38 +0100

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

Hei All,

ORD({31]) = MIN(INTEGER)

ORD({0..31}) = -1

etc if I remember right.

Now in C a unsigned integer is used for sets. So in C {31} regarded as an
unsigned integer has a different value from value to ORD({31}) in CP.

return( (double) y / (unsigned long) 0xffffffff) in C where y is a set would
translate into something like

int := ORD(y);
IF int < 0 THEN
    RETURN (int - 2 * MIN(INTEGER)) / 4294967295
ELSE
    RETURN int / 4294967295
END

Andrew


----- Original Message -----
From: "Campbell, Robert D (UK Edinburgh)" <robert.d.campbell{([at]})nowhere.xy
To: "BlackBox Mailing List" <blackbox{([at]})nowhere.xy
Sent: Wednesday, March 30, 2005 2:25 PM
Subject: [BlackBox] - Bit operations in Component Pascal



Or even simpler ?

  RETURN y / 4294967295.

Robert.

>>

>> I would say that the equivalent in CP for the C statement:
>>

>> return( (double) y / (unsigned long) 0xffffffff);
>>
>> Would be (assuming y is REAL):
>>

>> RETURN y / 0FFFFFFFFL;
>>
>> Note the L suffix to indicate that the constant should be

>> interpreted as a
>> LONGINT.
>>
>> Chris Burrows
>> CFB Software
>>
http://www.cfbsoftware.com
>>
>> > -----Original Message-----
>> > From: blackbox{([at]})nowhere.xy
>> > Behalf Of Andrew Thomas
>> > Sent: Tuesday, 29 March 2005 5:15 PM

>> > To: BlackBox Mailing List
>> > Subject: [BlackBox] - Bit operations in Component Pascal
>> >

>> > >
>> > > 2. What is the specific problem you have with the

>> return statement?
>> > >
>> >
>> > Hi Chris,
>> >
>> > the problem is that the divide is by MAX(unsigned integer)
>> >

>> > Andrew

********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

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

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



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

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIEhlaSBBbGwsXHBhcg0KXHBhcg0KT1JEKFx7MzFd
KSA9IE1JTihJTlRFR0VSKVxwYXINClxwYXINCk9SRChcezAuLjMxXH0pID0gLTFccGFyDQpccGFy
DQpldGMgaWYgSSByZW1lbWJlciByaWdodC5ccGFyDQpccGFyDQpOb3cgaW4gQyBhIHVuc2lnbmVk
IGludGVnZXIgaXMgdXNlZCBmb3Igc2V0cy4gU28gaW4gQyBcezMxXH0gcmVnYXJkZWQgYXMgYW5c
cGFyDQp1bnNpZ25lZCBpbnRlZ2VyIGhhcyBhIGRpZmZlcmVudCB2YWx1ZSBmcm9tIHZhbHVlIHRv
IE9SRChcezMxXH0pIGluIENQLlxwYXINClxwYXINCnJldHVybiggKGRvdWJsZSkgeSAvICh1bnNp
Z25lZCBsb25nKSAweGZmZmZmZmZmKSBpbiBDIHdoZXJlIHkgaXMgYSBzZXQgd291bGRccGFyDQp0
cmFuc2xhdGUgaW50byBzb21ldGhpbmcgbGlrZVxwYXINClxwYXINCmludCA6PSBPUkQoeSk7XHBh
cg0KSUYgaW50IDwgMCBUSEVOXHBhcg0KICAgIFJFV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ioqKioqKioqKioqKioqKlxwYXINClRoaXMgZW1haWwgYW5k
IGFueSBhdHRhY2htZW50cyBhcmUgY29uZmlkZW50aWFsIHRvIHRoZSBpbnRlbmRlZFxwYXINCnJl
Y2lwaWVudCBhbmQgbWF5IGFsc28gYmUgcHJpdmlsZWdlZC4gSWYgeW91IGFyZSBub3QgdGhlIGlu
dGVuZGVkXHBhcg0KcmVjaXBpZW50IHBsZWFzZSBkZWxldGUgaXQgZnJvbSB5b3VyIHN5c3RlbSBh
bmQgbm90aWZ5IHRoZSBzZW5kZXIuXHBhcg0KWW91IHNob3VsZCBub3QgY29weSBpdCBvciB1c2Ug
aXQgZm9yIGFueSBwdXJwb3NlIG5vciBkaXNjbG9zZSBvclxwYXINCmRpc3RyaWJ1dGUgaXRzIGNv
bnRlbnRzIHRvIGFueSBvdGhlciBwZXJzb24uXHBhcg0KKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKipccGFyDQpccGFyDQot
LS0gQmxhY2tCb3hccGFyDQotLS0gc2VuZCBzdWJqZWN0IEhFTFAgb3IgVU5TVUJTQ1JJQkUgdG8g
YmxhY2tib3hAb2Jlcm9uLmNoXHBhcg0KXHBhcg0KLS0tIEJsYWNrQm94XHBhcg0KLS0tIHNlbmQg
c3ViamVjdCBIRUxQIG9yIFVOU1VCU0NSSUJFIHRvIGJsYWNrYm94QG9iZXJvbn19AAAU4xNhYAsA
ABoAAAA=


----boundary-LibPST-iamunique-989502643_-_---
Received on Wed Mar 30 2005 - 14:45:38 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:28:19 UTC