On 3/27/01 1:14 AM, "Filip Sergeys" <[EMAIL PROTECTED]> wrote:
> 3)For the last two bits(3C) I like to have the binary value
> HEX value = 3C
> Binary = 111100
> Final SQL query: BIN(substring(HEX(intag), (length(HEX(intag))-1), 2))
Bin() takes an argument that is assumed to be deciaml. So bin is seeing 3c
which converted to an int would be 3 which is 11, yes?
Try this:
You are starting with a value: intag =262204
Converting to hex: hex(intag) = 4003c
Taking the last to characters: right(hex(intag),2) = 3c
Converting a HEX to binary: conv( right(hex(intag),2),16,2 )
since you said you want the last two bytes(chars) of the hex value, you can
use right() which is much easier to read in code than substring.
You need to use conv, to convert the hex to binary, because there isn't a
dec() function to go with bin() and hex(). (that would be conv(intag,16,10))
Hope that helps!
Lindsay Adams
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php