Forums > MaxMSP

negative hexadecimal conversion to integer, without FFFFFF prefix .

April 26, 2013 | 3:56 pm

hi all ,
i would lke to do this ,
how would you convert :

FFFFFF27 , to 2 and 7 ,
or , another example :
FFFFFF2E , to 2 and E

i still can’t get the way to remove those "F" , and separate the 2 numbers (or letters) following , in a list or else .
it seems so easy …

i ‘ll try to find out before anybody answers ,
and will triumph .

i’ m also ok to loose the challenge .

ready , go !

April 26, 2013 | 4:05 pm

here’s a patch that shows this

– Pasted Max Patch, click to expand. –
April 26, 2013 | 4:17 pm

Maybe this:

– Pasted Max Patch, click to expand. –
April 26, 2013 | 5:15 pm

hi Patrick ,
thanks for the patch ,
that bitwise intersection object obviously seems to be the key ,
i must admit i don’t understand yet … that’s very cool !
but i’m not sure we’re resolving my problem completely ,
maybe it’s done 99% , …
i’ll try to explain more .

the hex number we’re working on will always be in the range (-255 –> 0) , sorry the range (FFFFFF01 –> 0)
( i know numbers are numbers are numbers , but i think it’s important )
for the example of the value "FFFFFF2E" (-210) ,
i have to remove these FFFFFF ,
then we have 2E , or 2 and E .
i have to perform another conversion , which is (weird ?) :
2 has to be considered as an ASCII character , and converted to a decimal —-> 50
E has to be considered as an ASCII character , and converted to a decimal —-> 69

!!!!! and we’ve got it !!!!! 50 69

my problem is that i can’t get the letter "E" outputted, from a number box , even if it’s displaying hex .
it will only output decimal .

but maybe i have (once again) let some evidence come to me ,
without shaking hands .

i don’t think we can fill a message box with a letter , with this (thank you again) patch ,
can we ?


April 26, 2013 | 5:41 pm
– Pasted Max Patch, click to expand. –
April 26, 2013 | 7:43 pm

it seems to work perfectly , in all the cases ,

thank you very much Patrick
trop cool !

you surely saved me a looot of time ,
i now have to understand this "&" object .

that’s a good lesson to learn for me ,
let’s go !

wish you the best ,
have nice week-end


April 28, 2013 | 9:12 pm

did you know about the [atoi] object ?
you can also use regular expressions to strip the FFFFFF out of your message and use atoi to process the two remaining caracters…

– Pasted Max Patch, click to expand. –
April 29, 2013 | 7:49 pm

@(karrrlo): as joumik pointed out, a number is a number is a number, but it is not a symbol.
What he seems to manipulate are negative numbers, represented in hexadecimal. So you first need to convert the number in an hex symbol. I think this could be done with sprintf but I’m too far away from Max to be able to test this (I checked your patch using :-)
You’re right about atoi, of course. I just wanted to show joumik it was quite an obvious conversion to do without any specialized object.

May 17, 2013 | 3:23 pm

hi , thanks to both of you .

yes , atoi was very sexy !

everything ‘s working good now ,

thanks again


PS:   is very cool ! 


May 19, 2013 | 1:56 pm

@Patrick  Delges , i was’t exactly sure what Joumik needed as i was reading through the posts in diagonals , and it was a quick response i gave with the little time i had that day + your response was far more detailed  :)

and thanks for the link, this is just wonderful !!!

@joumik glad everything is working out for you



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