Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BitAnd() limitation?
Message
From
11/08/2004 16:44:40
 
 
To
07/08/2004 05:54:51
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00931430
Message ID:
00932491
Views:
13
hello Fabio

Sorry it took me so long to get back to you.

i have tryed to modify your first example for my needs, but i can not get it to work. here is what i have:
* *** the following returns .t. (correct)
?Test(;
	2^2 + ;
	2^2 + ;
	2^3 + ;
	2^4 + ;
	2^5 + ;
	2^6 + ;
	2^7 + ;
	2^8 + ;
	2^9 + ;
	2^10 + ;
	2^11 + ;
	2^12 + ;
	2^13 + ;
	2^14 + ;
	2^15 + ;
	2^16 + ;
	2^17 + ;
	2^18 + ;
	2^19 + ;
	2^20 + ;
	2^21 + ;
	2^22 + ;
	2^23 + ;
	2^24 + ;
	2^25 + ;
	2^26 + ;
	2^27 + ;
	2^28 + ;
	2^29 + ;
	2^33, ;
	2^33)

* *** the following returns .f. (incorrect)
?Test(;
	2^2 + ;
	2^2 + ;
	2^3 + ;
	2^4 + ;
	2^5 + ;
	2^6 + ;
	2^7 + ;
	2^8 + ;
	2^9 + ;
	2^10 + ;
	2^11 + ;
	2^12 + ;
	2^13 + ;
	2^14 + ;
	2^15 + ;
	2^16 + ;
	2^17 + ;
	2^18 + ;
	2^19 + ;
	2^20 + ;
	2^21 + ;
	2^22 + ;
	2^23 + ;
	2^24 + ;
	2^25 + ;
	2^26 + ;
	2^27 + ;
	2^28 + ;
	2^29 + ;
	2^30 + ;
	2^31 + ;
	2^32 + ;
	2^33, ;
	2^33)



Func Test
LPARA ;
	MasterBit, ;
	TestBit
LOCAL ;
	ReturnValue

* *** this only works from 0 to 53 (like 2^53)
IF IIF(;
		LOG(TestBit) / LOG(2) < 32, ;
		BITTEST(MasterBit, LOG(TestBit) / LOG(2)), ;
		BITTEST(MasterBit*2^-31, (LOG(TestBit) / LOG(2))-31))
	ReturnValue = .T.
ELSE
	ReturnValue	= .F.
ENDIF

RETURN(ReturnValue)
this still will not let me test correctly for large numbers. do you see what i am doing wrong here?
Thanks for your help.



>BITAND use only INTEGER32 values, then 2^31 set the bit 31 and the value is negative.
>
>
>?bitand(2^31, 2^31) = - 2^31      && shows .T.
>?BITTEST(bitand(2^31, 2^31),31)   && shows .T.
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform