How to select individual digits from a decimal number?


    Feb 25 2011 | 2:58 pm
    Hi, i have a problem i need to fix, i have a system giving a decimal number of 8 digits.
    eg. 10010001 (with no spaces)
    I need to be able to tell wether a certain digit in the number is 1 or 0, for example as above if digit 4 is at 1 then bang output, etc etc.
    any help would be great as i have searched the help files and consulted my collegues, i hope i am just overlooking something simple.
    thanks
    matomato

    • Feb 25 2011 | 3:10 pm
      I would also be very interested in knowing if this can be done easily, but i am working with binary numbers.
    • Feb 25 2011 | 4:51 pm
      Last time I looked, these questions were answered in the tutorials.
      With decimal use % and /.
      For instance, to get the hundreds digit [num]->[/ 100]->[% 10]
      To extract bits, use the [&] object to mask out the bit you're interested in, then optionally bit shift with [>>].
      For instance, to get bit 3 (counting from *right* starting with zero) [num]->[& 8]->[>> 3].
      If you just want to use the calculation to control a logic object (like if or a ggate), you can skip the bit shift.
      These are really not Max-specific questions, they are fundamental DP techniques.
    • May 17 2011 | 2:11 pm
      GREAT, thank you Vanille!