Extracting numbers from base 10
James Long
Posts: 1,181
I have a integer that is 4 places (ie, 1234)
I would like to extrapolate the lower two digits in decimal format.
I've scratched my head how to do this........without a large amount of instructions.· (ie.....only get 34 from the above number)
Anyone know of a simple method to extract the information with out a large number of calls.
It would be of great help,
James L
I would like to extrapolate the lower two digits in decimal format.
I've scratched my head how to do this........without a large amount of instructions.· (ie.....only get 34 from the above number)
Anyone know of a simple method to extract the information with out a large number of calls.
It would be of great help,
James L
Comments
Post Edited (TChapman) : 4/8/2007 3:03:26 AM GMT
I couldn't tell if you wanted each digit seperately or just the last two digits.
For the latter: x // 100 returns the remainder of a number divided by 100, or the last two numbers.
For the former: x // 10 to get the ones, then (x // 100) / 10·or (x / 10) // 10 to get the tens digit. If you want the result in ASCII for display purposes add $30 to each value.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
(assuming x := 3456)
x=//100
and I will get back
56
That is cool.....didn't know the // worked like that.
Thanks.....
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Thanks.....that is exactly what I needed.....I read that in the manual.....but it escaped me.
Thanks again......that will really help alot.
James L