List:General Discussion« Previous MessageNext Message »
From:Ed Reed Date:January 18 2006 9:24pm
Subject:Re: Converting decimal to binary
View as plain text  
Actually please ignore my previous question. I just had a brain cramp.
 
Thanks
 

>>> "Ed Reed" <EReed@stripped> 1/18/06 11:34:11 AM >>>
Can you (or anyone else) explain to me how, or point me somewhere that I can learn how
this works? I'd really like to know more about how bitwise arithmetic works.

Thanks

>>> Francesco Riosa < BastianBalthazarBux@stripped > 1/10/06 4:58:47 PM
> >>>
Francesco Riosa wrote:
> And another one is (in inverse order for laziness):
>
> select
> (8 & 1) AS `0`
> , (8 & 2 > 1) AS `1`
> , (8 & 4 > 1) AS `2`
> , (8 & 8 > 1) AS `3`
> , (8 & 16 > 1) AS `4`
> , (8 & 32 > 1) AS `5`
> , (8 & 64 > 1) AS `6`
> , (8 & 128 > 1) AS `7`
> ;
> 
but this one looks better:

select
(8 & 1) AS `0`
, (8 >> 1 & 1) AS `1`
, (8 >> 2 & 1) AS `2`
, (8 >> 3 & 1) AS `3`
, (8 >> 4 & 1) AS `4`
, (8 >> 5 & 1) AS `5`
, (8 >> 6 & 1) AS `6`
, (8 >> 7 & 1) AS `7`
;

http://dev.mysql.com/doc/refman/4.1/en/bit-functions.html 



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql 
To unsubscribe: http://lists.mysql.com/mysql?unsub=1 






Thread
Converting decimal to binaryEd Reed10 Jan
RE: Converting decimal to binaryGordon Bruce10 Jan
  • Re: Converting decimal to binaryBill Dodson10 Jan
Re: Converting decimal to binaryEd Reed18 Jan
Re: Converting decimal to binaryEd Reed18 Jan