Re: [BLACKBOX] Conversion & Casting

From: Campbell, Robert (SELEX GALILEO, UK) <robert.d.campbell{([at]})nowhere.xy>
Date: Tue, 26 Oct 2010 08:54:46 +0100

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

>> >-----Original Message-----
>> >From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
>> >Sent: Tuesday, 26 October 2010 7:41 AM
>> >To: BLACKBOX{([at]})nowhere.xy
>> >Subject: [BLACKBOX] Conversion & Casting

>> >On 21/10/2010 23:32, Chris Burrows wrote:

>> >What (*does*) SYSTEM.VAL do when the input and output have
>> >differing numbers of
>> >bits?



>> I did a quick test and found that BlackBox happily compiles and runs
>> something like the following:
>>
>> TYPE
>> String = ARRAY 256 OF CHAR;
>>
>> VAR
>> s: String;
>> i: INTEGER;
>> ...
>> ...
>> s := '123';
>> i := SYSTEM.VAL(INTEGER, s);
>>
>> The resulting value of i is 00320031H so it looks like it's
>> just typecast
>> the first corresponding number of bits.
>>
>> I've made a mental note to be even more careful in future when using
>> SYSTEM.VAL ;-)


An interesting partial answer.

What about:

VAR
  b : BYTE;
  s : SET;
BEGIN
  b := SYSTEM.VAL(BYTE, s);
  s := SYSTEM.VAL(SET, b);


In the first line which byte of s is taken?. I guess there is no
definitive answer, a separate experiment needs to be done for each
compiler.


In the second line where is b put, and what goes into the rest of s?
This is more difficult because if an experiment says b is padded with
zeros
we do not know if this is deliberate, and thus repeatable, or accidental
and maybe
not repeatable.


Even if SYSTEM.VAL varies from compiler to compiler, it would be good if
it were documented
for each compiler.


Cheers

Robert
SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
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.
********************************************************************


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-857313447_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwID4+ID4tLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0t
LVxwYXINCj4+ID5Gcm9tOiBCbGFja0JveCBbbWFpbHRvOkJMQUNLQk9YQExJU1RTLk9CRVJPTi5D
SF0gT24gQmVoYWxmIE9mIFJvYmVydFxwYXINCj4+ID5TZW50OiBUdWVzZGF5LCAyNiBPY3RvYmVy
IDIwMTAgNzo0MSBBTVxwYXINCj4+ID5UbzogQkxBQ0tCT1hATElTVFMuT0JFUk9OLkNIXHBhcg0K
Pj4gPlN1YmplY3Q6IFtCTEFDS0JPWF0gQ29udmVyc2lvbiAmIENhc3RpbmdccGFyDQpccGFyDQo+
PiA+T24gMjEvMTAvMjAxMCAyMzozMiwgQ2hyaXMgQnVycm93cyB3cm90ZTpccGFyDQpccGFyDQo+
PiA+V2hhdCAoKmRvZXMqKSBTWVNURU0uVkFMIGRvIHdoZW4gdGhlIGlucHV0IGFuZCBvdXRwdXQg
aGF2ZSBccGFyDQo+PiA+ZGlmZmVyaW5nIG51bWJlcnMgb2YgXHBhcg0KPj4gPmJpdHM/XHBhcg0K
XHBhcg0KXHBhcg0KPj4gSSBkaWQgYSBxdWljayB0ZXN0IGFuZCB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KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioqKioqXHBhcg0KVGhpcyBlbWFpbCBhbmQgYW55IGF0dGFjaG1l
bnRzIGFyZSBjb25maWRlbnRpYWwgdG8gdGhlIGludGVuZGVkXHBhcg0KcmVjaXBpZW50IGFuZCBt
YXkgYWxzbyBiZSBwcml2aWxlZ2VkLiBJZiB5b3UgYXJlIG5vdCB0aGUgaW50ZW5kZWRccGFyDQpy
ZWNpcGllbnQgcGxlYXNlIGRlbGV0ZSBpdCBmcm9tIHlvdXIgc3lzdGVtIGFuZCBub3RpZnkgdGhl
IHNlbmRlci5ccGFyDQpZb3Ugc2hvdWxkIG5vdCBjb3B5IGl0IG9yIHVzZSBpdCBmb3IgYW55IHB1
cnBvc2Ugbm9yIGRpc2Nsb3NlIG9yXHBhcg0KZGlzdHJpYnV0ZSBpdHMgY29udGVudHMgdG8gYW55
IG90aGVyIHBlcnNvbi5ccGFyDQoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKlxwYXINClxwYXINClxwYXINCi0tLS1ccGFy
DQpUbyB1bnN1YnNjcmliZSwgc2VuZCBhIG1lc3NhZ2Ugd2l0aCBib2R5ICJTSUdOT0ZGIEJMQUNL
Qk9YIiB0byBMSVNUU0VSVkBMSVNUUy5PQkVST04uQ0hccGFyDQp9
----boundary-LibPST-iamunique-857313447_-_---
Received on Tue Oct 26 2010 - 09:54:46 UTC

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