123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|659|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> C/C++/C#/Other -> slitting a number into parts?

Sat, 12 May 2007, 16:58
spinal
This might seem simple to some people, and I swear I have managed this once before, but...

How can i split a number into digits?

e.g.

turn this -
12345

into this -

1
2
3
4
5

so I can use it for sprite framenumbers or something.

Thankyou.

-=-=-
Check out my excellent homepage!
Sat, 12 May 2007, 17:15
mike_g
You could convert it to a string. Then run through each character. If you want the numbers in an integer array or something copy the characters to the array and subtract 48 from the ascii value.

Theres probably an easier way, but from what I know thats how I would do it.
Sat, 12 May 2007, 17:21
Jayenkai


OK, that'll do it in Blitz.

For C..

(excuse my lack of having tested this!)


You'll probably have to tweak that a few hundred times to get it working right, but.. Should kinda work, ish!

-=-=-
''Load, Next List!''
Sat, 12 May 2007, 17:27
mike_g
Oh yeah. Dividing and Modding it should be easier.
Sun, 13 May 2007, 10:20
spinal
Thanks guys, my first reason for this was to display a seconds counter (only two digits) I did it this-wize -


-=-=-
Check out my excellent homepage!