### Decimal to Binary, not binary to decimal.

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.

**all**of the following text. Then, in Max, select

*New From Clipboard*.

----------begin_max5_patcher---------- 790.3oc2Y10aaBCEF9Z3WAhK1UYQ1FLerKpz9cLUUQR7ZcUvDANcYqp+2G1F VSqZRNsC6ZwMfvXvu75yywevigAwqZNv5hi9VzOhBBdLLHPWjpffgqChqqNr daUmtZwB1uZVce7BysjrCRcwWcUT9XgM6kaYR4u2wLu3XtnuRWObWw9Ztn+9 5WGYnvcUx02wE2dSKasz7TYjknEQ3rB0oDp5HAsD8u2Ceitg6EyWIoiM8OaD RQUstgi+dKuZa7yMqQW51EeT863+QWebeCpJ8ovP0gEPMj80qXsm8aeQT7pJ wsmvCvWxCHHr5DEcVOf9d8fm8919ZKYs2vDUq1peNzI7mwGok0wDxJIuQbjb wDidw59Lzvgnq+Ht5aGl8k91nvJwYlHrTxY83rOy3rSBdYSqgfIkvIO7Lk7F LAXnGwCPuxbC5kYOzKK0NAZlPrKDnk3knGchcjxDvnGtXthdFS.D5gK8.zaX TZahdID6DnAB8PdI5MwIiHzB3nGclhdCl.LzK6yG8HDiDw4VbBmY1IPCB5gy 8RzKYZcjDx6XTOxLE8FLAXnWhGfdkCi5UZOzqvNwYCjGYI8LVbpWRdS7z.RJ xASdkyUvy3Av.OjG.dXj0mtYpcBy.AdXuD7vSqijZhy.Ady004kNxZ..ubOX YdTsNwEo1i6H1IJCB2MYas4k1hXSp.J5+2EsXrIECe1XNYi2mzUzLsQYCdEn nrj4Ptr9h306qOt65j+WAZNf8O1wAPZMDukKd8e9S+UnJ+ktXWy910i1z3+a K54OkMrNIWnI8iqD8EU5N9lMLwwJbCuSIZsO718mf0SFD8j5N8.QNY9kbRbm bvPzCwc5IAhdv9U2ExYxQ8eFtndT6CuqrGDD8T3UcWp8wyUcWTH5wcIed0m9 IzC0u5tb2PEXP5wcImwPFZGS7qtK2katDhbbXtYHCk5tTyPFovcYBgLoP+ZX B+ZJgtKoCjIf8QGgvrXmpc6df01M7J0Boewg22zptLaQnYUclK0KyKtk8.er 945RpZ6Whmre8c6aMqP6PQVbnpcdJ7u.5GrboB -----------end_max5_patcher-----------

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.

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

or use this…

- This reply was modified 11 months by Teb Geronimo.

Forums > MaxMSP