separating individual digits of decimal number
msiriwardena
Posts: 301
What I would like achieve is to separate the individual numerals of a decimal number.
Like variable x value = 1234
the individual numerals 1,2,3,4 in different variables.
example : to place 1 in a variable a, 2 in a variable b and 3 in a variable 3 etc.
Thank you.
Siri
Like variable x value = 1234
the individual numerals 1,2,3,4 in different variables.
example : to place 1 in a variable a, 2 in a variable b and 3 in a variable 3 etc.
Thank you.
Siri
Comments
Anyway in spin you can split a number into the last digit and the rest with / and // operators - or something like that - the remainder gives the last digit, then divide by ten and repeat - unfortunately
that yields them in the wrong order for most uses. If you are only interested in, say, 3 digits its easy
to pick them out:
Thanks for you help.I was looking at the code from a clock and then I thought may be there are better ways.
Thanks again for the quick answers.
Siri
Thanks for the code snippet.Looks very elegant.Will give it a try.
Siri