Numeric access to char[]

nobody nobody at mailinator.com
Wed Aug 23 05:14:23 PDT 2006


Chad J wrote:
> nobody wrote:
> ....
>>
>> So you will have to do it manually. I would like to suggest that if 
>> you can pad the char[] to ensure its .length % 8 == 0 then you can 
>> cast it to a ulong and your shifting will be faster.
> 
> Sure about ulong?  In my spare time I made my own minimal Bignum 
> implementation.  I'm not sure about shifts, but for addition with 
> carrying it was faster to use size_t (uint in this case) rather than 
> ulong.  I wonder if maybe the compiler could optimize it better if it 
> didn't have to emulate 64 bit integers.  Or my benchmark was borked.

I certainly could be wrong but I would be quite surprised. I would be interested 
to see what tests you ran that suggest addition with carry was faster.



More information about the Digitalmars-d-learn mailing list