Forums > MaxMSP

Decimal to Binary, not binary to decimal.

Apr 28 2014 | 1:36 pm

I know I’ve seen this somewhere before, but I can’t find it anywhere now so I apologise if this has been asked and answered in the past.

I am trying to convert decimal numbers into binary in such a way that the individual bits are separate from each other and the numbers are always represented by 8 bits. For example, I would like to have the number 2 come out as 0, 0, 0, 0, 0, 0, 1, 0 with each of those digits in separate integer boxes.

The display options in the inspector for the integer box does not achieve the result I am looking for. I have seen many, many different implementations of binary to decimal, but I need decimal to binary. I have seen java and javascript and external modules/extensions/etc recommended and used but I am trying to find (and am certain I have seen before) a solution which does not use anything outside of the native Max 6 environment. I have been going around in circles all day. I am sure there is a way to use bitwise operators to do this but I can’t seem to get my head around it.

Any help would be greatly appreciated. Thanks so much.

Apr 28 2014 | 2:20 pm

-- Pasted Max Patch, click to expand. --

Apr 28 2014 | 2:52 pm

Thanks a million for that, Jesse. It is exactly what I was trying to do, and very close to what I had been messing about with but I obviously didn’t have a clear idea of how the "&" operator works. Thanks again.

Apr 28 2014 | 4:41 pm

Also.. if you need to distribute an existing bit list to individual number boxes, [listfunnel] –> [spray] works well.

Mar 05 2015 | 5:39 am

or use this…

Viewing 5 posts - 1 through 5 (of 5 total)

Forums > MaxMSP