|
[Date Index]
[Thread Index]
[Author Index]
Re: Operating with binary numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg59075] Re: Operating with binary numbers
- From: "Carl K. Woll" <carlw at u.washington.edu>
- Date: Thu, 28 Jul 2005 02:26:42 -0400 (EDT)
- Organization: University of Washington
- References: <dc77gl$k5p$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"Wishmaster" <wishmaster at imaginary.marreka.no-ip.com> wrote in message
news:dc77gl$k5p$1 at smc.vnet.net...
> Hello,
>
> I found that you can represent binary numbers in Mathematica with this:
>
> binary = 2^^110110101010111010
> 223930
>
> And BaseForm[binary, 10] returns the number in decimal form
> 223930
>
> I'd like to know if is there some function to test if a given bit of the
> binary number is on, and to do operations like "shifting" the binary
> number.
> I looked at the help but can't find anything.
>
> I use Mathematica 5.0 on Windows XP.
>
To test whether a bit is on, use BitAnd. The following tests the last 5
digits of binary:
In[7]:=
Positive[BitAnd[binary,2^{4,3,2,1,0}]]
Out[7]=
{True,True,False,True,False}
For shifting binary numbers, you may use the BitShift* functions in the
Developer` context:
Developer`BitShiftRight
Developer`BitShiftLeft
Carl Woll
Wolfram Research
> Thanks.
> --
> []s Renan (aka Wishmaster) - Canoas, RS, Brazil
> "Rumor has it that, when they shut down the IBM 7094 at MIT in 1973,
> they found a low-priority process that had been submitted in 1967 and had
> not yet been run. " -- From Silbershatz and Galvin, pp. 142-143.
>
Prev by Date:
Re: Showing Mathematica notebooks within Firefox browser (like Adobe PDF's)
Next by Date:
Re: How to simplify an expression in version 5
Previous by thread:
Re: Operating with binary numbers
Next by thread:
Re: Operating with binary numbers
|