# 180: 100 = 1 help pls

### » Wed Mar 28, 2012 9:10 pm

Hi i need help with this
i have for example: 180:100 and i need from this 1 (in pascal is it maybe DIV or MOD) or i have 179 : 10 i need 17. PLs help i do not know how to.
B
25
S
4
G
2
Posts: 318
Reputation: 2,471

### » Wed Mar 28, 2012 10:14 pm

If you need the remainder of a division, then it is modulo. The sign used for modulo division is %

180 % 100 = 80
179 % 10 = 9

But you seem to simply need the integer division, which rounds down to the next integer. That's int(somecalculation) or floor(somecalculation)

int(180/100) = 1
int(179/10) = 17
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

### » Thu Mar 29, 2012 7:35 pm

yea it is! :) ty but how i create from 180 alone digit 8 or 1 or 0? is this possible?
B
25
S
4
G
2
Posts: 318
Reputation: 2,471

### » Thu Mar 29, 2012 8:25 pm

[QUOTE=Raiper341] yea it is! :) ty but how i create from 180 alone digit 8 or 1 or 0? is this possible?[/QUOTE] Of course, it is :)
Convert the number to a string, then loop through the length of the string and extract one letter each time.

number to string conversion: string = str(number)
getting the length of a string: length = len(string)
get a substring at any position: substring = mid(string, start, length)
looping: For (name, start, end), use 1 for start and len(string) for end
within the loop use mid(string, loopindex, 1) to get one letter at that position

To convert a string to a number, use int(string) again.

Here is a very simple cap: numbertodigits.cap

Have a look at the Construct wiki, explaining all of the expressions: System expressionstulamide2012-03-29 20:27:09
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

### » Sat Mar 31, 2012 6:19 pm

Thx Tulamide :)
B
25
S
4
G
2
Posts: 318
Reputation: 2,471