トピック
falnshower TheFinalAct1

How to split a numerical variable?

Does anyone know how to split a numerical value with a maximum of 5 characters (maximum amount of 99999) into five seperate variables? I want to make a sprite based counter for my game.
2そうだね
未プレイ
返信[1]
親投稿
Oscar PwnageBlock
Use the DIV and MOD instructions. DIV returns the integer division of two values and MOD returns the remainder of the integer division. You can employ these two operators in a way that you can get each individual digit in a number. For example... 10298 MOD 10 will return 8. 10298 DIV 10 will return 1029. 1029 MOD 10 will return 9. 10298 DIV 100 will return 102. Etc.
2そうだね
プレイ済み
返信[2]
親投稿
falnshower TheFinalAct1
Okay, thanks
0そうだね
未プレイ
返信[3]
親投稿
Stewart segludian
Attached is some example code.
1そうだね
プレイ済み
返信[4]
親投稿
Alex MrCashews
This might be easier: DEF DIGITS N% OUT A%,B%,C%,D%,E% VAR S$=FORMAT$("%05D",N%) A%=VAL(S$[0]) B%=VAL(S$[1]) C%=VAL(S$[2]) D%=VAL(S$[3]) E%=VAL(S$[4]) END
0そうだね
プレイ済み