Binary to Decimal
Hi
I was wondering if anyone has objects that I could use that allows the conversion of Decimal numbers to Binary ?
Cheers
Guy
What do you intend to do with the binary data? If it's just for display purposes, the standard number box can display as binary.
Just to clarify: numbers in Max are *always* binary (they can't be anything else internally). And they are *always* displayed in decimal (with the exception of the formatting options in numbox and flonum).
On 2008 Aug 26, at 11:11 PM, Guy Ben-Ary wrote:
> I was wondering if anyone has objects that I could use that allows
> the conversion of Decimal numbers to Binary ?
Hi. There is an object in Tap.Tools called tap.bits which converts
between lists of ones and zeros and integers. The URL is below.
best,
Tim
____________________________________
Tap.Tools - Objects for Max, MSP, and Jitter
http://electrotap.com/taptoolsmax/
Here's your answer.
I can do a binary to decimal converter too if you wish?
You'll can put [zl rev] after it depending if you want the MSB of the LSB first.
Output is always MSB first and input should always be MSB first though you can change these around with [zl rev].
Output in binary is as a list, input should be as a list too. The patch show the usage. Hopefully this helps?
This .js patch yields a '1' - on my system - when a '0' decimal is input.
On Wed, Aug 27, 2008 at 9:03 AM, fairesigneaumachiniste
wrote:
>
> You'll can put [zl rev] after it depending if you want the MSB of the LSB
> first.
>
Here's an abstraction that takes binary numbers as lists and converts them. It uses only standard objects so doesn't require a js or any externals.
lh
Nice patch, thereishopeforus!
Here's the same patch, but I've made a few cosmetic simplifications.
Zachary
Whoops! Thanks for that. I didn't test extensively (i.e. not at all).
So, to make up for that I give you the new version. Numbers no longer need to be a list if they are in binary format. Just send a message like this [binary 101101] for example and it will convert to decimal. Also, sending [decimal 10] will output 1010 as a message, not as a list.
And the right output also outputs the value as Hex.
Hope this is useful.
Ah [listfunnel]!
I can never decide whether I love it or hate it when i find an object that does in one step what I've been doing in twenty, especially if it's been staring me in the face for a while.
Also the last bit can be replaced by [zl sum].
lh
On Aug 27, 2008, at 9:23 AM, Luke wrote:
> I can never decide whether I love it or hate it when i find an
> object that does in one step what I've been doing in twenty,
> especially if it's been staring me in the face for a while.
If you're willing to install the Jasch objects, there's bitlist which
does bidirectional conversion. There are many useful objects in this
collection.
-C
Chris Muir
cbm@well.com
http://www.xfade.com
Yes, the jasch objects are great.
Here is a slight modification so that it only outputs when it has finished summing the values. Otherwise, it outputs an integer for every bit. Also: the expr still works if you don't unpack the list, and I took out the "1" from the listfunnel, so the "- 1" is no longer necessary.
Quote: Zachary Seldess wrote on Wed, 27 August 2008 11:32
----------------------------------------------------
> Nice patch, thereishopeforus!
>
> Here's the same patch, but I've made a few cosmetic simplifications.
>
> Zachary
Luke schrieb:
> Here's an abstraction that takes binary numbers as lists and converts
> them. It uses only standard objects so doesn't require a js or any
> externals.
And this is my version of the same...
--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com
Hi,
Just a follow up. I'm rather (extremely) new to Max MSP, but I can't figure this out.
I want to take a binary list and essentially chunk it into bytes. Another words, assuming I have some arbitrarily large list of bits (8 * X bytes), how do I get it to operate on the first 8 bits, then the next 8 bits, then the next, etc.
Assume the list in byte order. This means that the first 8 bits in the list should become the first byte in the resulting list. If there were 64 bits in the list, the result should be 8 bytes long.
Here's a visual representation. It doesn't work as it just creates an int from the entire binary string. It shows a 64 bit list and I've for illustration purposes created a fake output of 8 bytes that represents the values of the bits (top row of bit = first byte in output message.)
Any help would be appreciated. Thanks.
Figured it out.
used 'zl iter' with a chunk size of 8.
i also have an abstraction which does this, but it outputs
the "binary" digits to individual outputs - because as
you might have noticed, you can not display 7777777 as "binary"
in max, it is simply a too long number, only up to 256 it will
fit into 8 digits.
Problem with converting large binary list in chunks.
Hi, was using the some of the above binary to int converters on a largish list and I'm getting inconsistent results with the output.
I'm new to this, so I'm having a hard time figuring out why it's not working as expected. On the patch below is a 24x16 binary list. I iterate 4 bits at a time into "bintoi" and should get 96 integers out. The results should be what you see in the "Expected Result" message, but they are not.
Can't figure out what I'm doing wrong. Any thoughts?
(This is an example. In the real life version, the binary list is being created by jit.spill from a matrix via an expression.)
You're feeding more numbers to zl iter then the default size. Make it a [zl 384 iter 4] to change that default. Below are by the way other ways of making the conversion without math.
Thanks for the help. It totally fixed the problem I was having.
Thanks for this! This is super useful :))