List:General Discussion« Previous MessageNext Message »
From:Gerald Clark Date:March 28 2001 4:30pm
Subject:Re: Converting Decimal value to Binary
View as plain text  
BIN(intag & 255)

Filip Sergeys wrote:
> 
> Hi,
> 
> WHAT DO I WANT TO DO:
> 
> I want to have the binary value of a part of a decimal value.
> 
> 1)I have a decimal value  in column called intag : 262204
> 
> 2)From this value I'am only interested in the last two bits of the HEX value of
>    this decimal
>         HEX value = 4003C
>         My interest 3C
>         part of used SQL query: substring(HEX(intag), (length(HEX(intag))-1), 2)
> 
> 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))
> 
> PROBLEM
> When running the last query, the returned value is 11 instead of 111100.
> Probably it has something to do with the fact that I requested a substring of
> length 2. What do I need to do to get the complete binary value?
> 
> If one you SQL geniuses knows this, please let me know.
> 
> Thanks in advance
> 
> FS
> 
> ---------------------------------------------------------------------
> 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 <mysql-thread69616@stripped>
> To unsubscribe, e-mail
> <mysql-unsubscribe-gerald_clark=suppliersystems.com@stripped>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Thread
Converting Decimal value to BinaryFilip Sergeys27 Mar
  • Re: Converting Decimal value to BinaryLindsay Adams27 Mar
  • Re: Converting Decimal value to BinaryGerald Clark28 Mar