- Bit operations in Component Pascal

From: Andrew Thomas <"Andrew>
Date: Tue, 29 Mar 2005 08:44:45 +0100

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


----- Original Message -----
From: "CFB Software" <info{([at]})nowhere.xy
To: "BlackBox Mailing List" <blackbox{([at]})nowhere.xy
Sent: Saturday, March 26, 2005 12:48 AM
Subject: [BlackBox] - Bit operations in Component Pascal


> 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?
>

Hi Chris,

    the problem is that the divide is by MAX(unsigned integer)

Andrew

> 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
>
>

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



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

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZ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A


----boundary-LibPST-iamunique-1221544808_-_---
Received on Tue Mar 29 2005 - 08:44:45 UTC

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