Re: Problem with AND &
Mike wrote:[color=blue]
> Okay, start from scratch.
>
>
> Define code
>
> define('CERTACC ESS_MEMENTRY', 0x01);
>
>
> Function
>
> function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
> //AND = 1 IF BOTH are 1
> echo "<P>SecurityLev el_Check";
> $binanswer = $security_byte & $securitylevel_ bit;
> echo "<P>nonbin byte=".$securit y_byte." /bit=".$security level_bit." /nonbin result is ".$binanswe r;
> return $security_byte & $securitylevel_ bit; }
>
>
> $securitylevel_ bit is the defines like the one above. The $security_byte is the data in the database
> record for a person.
>
>
> Output is
> SecurityLevel_C heck
>
> nonbin byte=xFE /bit=2 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=xFE /bit=1 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=xFE /bit=4 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=xFE /bit=8 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=xFE /bit=16 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=xFE /bit=32 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=xFE /bit=128 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=0x00 /bit=1 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=0x00 /bit=2 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=0x00 /bit=4 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=0x00 /bit=8 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=0x00 /bit=16 /nonbin result is 0
>
>[/color]
Mike,
You're getting closer - but you're still passing the STRING "xFE" as the
first parameter, not a HEX value. When converted to a number for the
bit operations, the string will be converted to zero.
You need to pass a numeric value to the function.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attgl obal.net
=============== ===
Mike wrote:[color=blue]
> Okay, start from scratch.
>
>
> Define code
>
> define('CERTACC ESS_MEMENTRY', 0x01);
>
>
> Function
>
> function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
> //AND = 1 IF BOTH are 1
> echo "<P>SecurityLev el_Check";
> $binanswer = $security_byte & $securitylevel_ bit;
> echo "<P>nonbin byte=".$securit y_byte." /bit=".$security level_bit." /nonbin result is ".$binanswe r;
> return $security_byte & $securitylevel_ bit; }
>
>
> $securitylevel_ bit is the defines like the one above. The $security_byte is the data in the database
> record for a person.
>
>
> Output is
> SecurityLevel_C heck
>
> nonbin byte=xFE /bit=2 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=xFE /bit=1 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=xFE /bit=4 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=xFE /bit=8 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=xFE /bit=16 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=xFE /bit=32 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=xFE /bit=128 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=0x00 /bit=1 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=0x00 /bit=2 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=0x00 /bit=4 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=0x00 /bit=8 /nonbin result is 0
>
> SecurityLevel_C heck
>
> nonbin byte=0x00 /bit=16 /nonbin result is 0
>
>[/color]
Mike,
You're getting closer - but you're still passing the STRING "xFE" as the
first parameter, not a HEX value. When converted to a number for the
bit operations, the string will be converted to zero.
You need to pass a numeric value to the function.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attgl obal.net
=============== ===
Comment