Welcome to the Parallax Discussion Forums, sign-up to participate.

# Programing help in spin

Posts: 144
I would like to find out how many thousands,hundreds,tens and singles in a number Ex: 6476, and place each category in varibles Ex: singles,tens,hundreds and thousands

Any help with an example in spin will be greately appriciated.

Thank you.

Siri

• Posts: 988
something like:
```   singles := number//10
tens := (number/10)//10
hundreds := (number/100)//10
thousands := number/1000
```
Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
• Posts: 144
@tomcrawford

Thank you
I will give ita try

Siri
• Posts: 6,153
edited 2018-08-06 - 19:21:12
Tom's code works (I tested) -- I borrowed from it to create this method that lets you set the number of digits captured from a value, always starting from the 1s end.
```pub get_digits(value, digits, p_digits)

repeat digits
byte[p_digits++] := value // 10
value /= 10
```
This works, too. Call it like this:
```  get_digits(myValue, 4, @singles)
```
Jon McPhalen
Hollywood, CA
It's Jon or JonnyMac -- please do not call me Jonny.
• Posts: 988
Of course, it you want to fiddle with larger numbers you can use this from OBEX.
Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.