|
Kain Cleaver
Registered User
Join date: 24 Jan 2006
Posts: 178
|
10-20-2006 23:28
Hi there . i need help converting one solid number into several numbers that make it up
in otherwords i need to know the command to use to convert
a = 123456
into
b = 1 c = 2 d = 3 e = 4 f = 5 g = 6
in other words split a into bcdefg
i know its possible because there are progressive slots and slot machines that use a LED display .. i just dont know where to begin to look. can someone guide me in the correct direction for this? thank you
|
|
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
|
10-20-2006 23:55
|
|
Ayrn Wake
Registered User
Join date: 7 Jan 2006
Posts: 39
|
10-21-2006 05:54
Having done this myself, theres a number of ways you can handle it. The way most simple to my mind is to split the number up like this:
integer base = 123; integer hundreds = llFloor ( base / 100 ); integer tens = llFloor ( ( base - hundreds ) / 10 ); integer digits = base - hundreds - tens;
Though I just did this on the fly, so you might need to adjust data types (llFloor for instance works on floats, not integers, and I can't remember what type the division returns if integers used. If it does need floats, then try using the division number as a float, eg, 100.0, or use (float)base, etc).
|
|
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
|
10-21-2006 21:14
From: Kain Cleaver Hi there . i need help converting one solid number into several numbers that make it up
in otherwords i need to know the command to use to convert
a = 123456
into
b = 1 c = 2 d = 3 e = 4 f = 5 g = 6
in other words split a into bcdefg
i know its possible because there are progressive slots and slot machines that use a LED display .. i just dont know where to begin to look. can someone guide me in the correct direction for this? thank you Usin the modulo (remainder) operator: a = 123456
b = a % 10 c = (a / 10) % 10 d = (a / 100) % 10 e = (a / 1000) % 10 f = (a / 10000) % 10 g = (a / 100000) % 10
|