Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bitand on more than 32 bits
Message
De
11/02/2003 05:06:25
 
 
À
11/02/2003 03:53:34
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00751377
Message ID:
00751816
Vues:
24
>Hi,
>
>>>Just tested (you never know with computers): bitand(2^32, 2^32) returns 0 since we are exceeding 32 bits (2^31 ..... 2^0)
><<
>
>Yea, you're right - realised my example was only 24 bit straight after posting. So how about, for x and y:
>
>nresult = BITAND(int(x/0xffffffff),int(y/0xffffffff))* 0xffffffff ;
>+ BITAND(Mod(x,0xffffffff),mod(y,0xffffffff))
>
>
>Regards,
>Viv

Viv,

Don't think that will work if you want to store it all in one numeric variable (internally kept as a double)

Don't recall the internal format of a double (ie, the number of bits for the mantissa is 52 or 53 bits I believe). Looking at the system capacities, they say 16 digits of precision

16 digits : ln(10^16)/ln(2) = 53.15 bits = ln2(10^16)

Doing a test:
a=0xffffffff * 2^32 + 0xffffffff
?mod(a,0x80000000) yields 0.00, ie precision lost

You can safely go up to 52 bits.

Cheers,
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform