Jump to content
Sign in to follow this  

bit_test function?

Recommended Posts


Is there a way to do something similar to c language bit_test?

That is, to test if a bit in a binary representation is a 1?


$var = 5; = 0x05  = 0000 0101
bit_test( $var, 2 ); returns true because bit 2 (which is third from the right) is a 1
bit_test( $var, 1 ); returns false because bit 1 (2nd from the right) is a 0
bit_test( $var, 0 ); returns true
; and so on. bits 3 thru 7 all return false

I searched the help and forum here for "bit_test" "bit test" "bit tester"


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this