- Bit operations in Component Pascal

From: CFB Software <"CFB>
Date: Sat, 26 Mar 2005 10:18:54 +1030

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

Andrew,

1. Generally, the Component Pascal MOD operator is the equivalent of the %
(modulus) operator in C. Note that MOD is defined in terms of DIV and CP DIV
always rounds toward negative infinity. Most C-language implementations
normally round towards zero.

2. What is the specific problem you have with the return statement?

Regards,

Chris Burrows
CFB Software
info{([at]})nowhere.xy
http://www.cfbsoftware.com


>
> -----Original Message-----
> From: blackbox{([at]})nowhere.xy
> Thomas
> Sent: Friday, 25 March 2005 12:52 AM
> To: BlackBox Mailing List
> Subject: [BlackBox] - Bit operations in Component Pascal
>
>
> Moi,
>
> Yes SET is great and it is easy to go from SET to INTEGER. Things are much
> uglier in C. However C has an 4 byte unsigned integer and you can
> manipulate
> this as bits using <<, >>, ^ etc. This is very useful for writing random
> number generators where you can write

<snip>
> x[kk] = x[kk+M] ^ (x[kk] >> 1) ^ mag01[x[kk] % 2];

<snip>
> return( (double) y / (unsigned long) 0xffffffff);
>
> The problem I have with the C code is x[kk] % 2 and the return statement.
> What is the best thing to do in CP?
>
> Regards
> Andrew
>
>

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



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

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXH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 26 2005 - 00:48:54 UTC

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