negative hexadecimal conversion to integer, without FFFFFF prefix .

joumik's icon

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 !

joumik's icon
Max Patch
Copy patch and select New From Clipboard in Max.

here's a patch that shows this

pdelges's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Maybe this:

joumik's icon

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 ?

Matthieu

pdelges's icon
Max Patch
Copy patch and select New From Clipboard in Max.
joumik's icon

oooooo
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

Matthieu

(karrrlo)'s icon
Max Patch
Copy patch and select New From Clipboard in Max.

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...

pdelges's icon

@(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 http://www.ahmetkizilay.com/ptc/ :-)
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.

joumik's icon

hi , thanks to both of you .

yes , atoi was very sexy !

everything 's working good now ,

thanks again

Matthieu

PS:   http://www.ahmetkizilay.com/ptc/   is very cool ! 

(karrrlo)'s icon

@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  http://www.ahmetkizilay.com/ptc/ link, this is just wonderful !!!

@joumik glad everything is working out for you

keepsound's icon

Max Patch
Copy patch and select New From Clipboard in Max.