Hello,
I'm currently converting some C code to PB, and have some trouble with the code below.Hope
someone could help to shed some light over the issue.
C Code:
' unsigned long long U64,BB,Bittmap,DEBRUIJN64
' DEBRUIJN64 = U64(0x07EDD5E59A4E28C2)
'((bittmap & -bittmap) * DEBRUIJN64) >> 58
' my addition just to test the expression
' BB = ((bittmap & -bittmap) * DEBRUIJN64)
PB Code:
Local BB,Bittmap,DEBRUIJN64 As QUAD
DEBRUIJN64 = &H07EDD5E59A4E28C2
BB = (Bittmap And -Bittmap) * DEBRUIJN64
Shift Right BB,58
? "BB:" + Str$(BB)
Is my convertion from C to PB correct?
Using different values for the Bittmap variable(input), I get different result
in PB compared to what I get from C - using the same input values. In PB the BB variable is always
assigned the value of -92337203685478E+18, while in C I get different output to the BB variable -
and they are all positive values - for the same input values of Bittmap used in PB.
Is this a question of signed versus unsigned 64 bit integers?
How can I convert a Quad in PB to an unsigned 64 bit integer?
Would it help?
I'm on Win7 64 bit and using VC++ 2010 Express as C compiler.
Maybe unsigned long long is larger than 64 bits on such a system, but I don't think so
since sizeof(unsigned long long) returns 8.
Thanks for your time!
--
OB