How do I pick only the first value of a 2 digit int-checksum

Just started using Construct 2? Post your questions here

» Sun May 31, 2015 12:17 pm

Hi folks, i hope you can help me with this small problem.

the user enters two numbers, from which the programm calculates the cross sum and stores it in a variable.
for example 4 | 5 = 9

Problem is the cross sum can only habe one diget.
so if the user enters 8 | 9 =17
then the program should pick the 1 and the 7 and calculate the cross sum again:
8 | 9 =17
1 | 7 = 8

i undersstand that i can check if the result is bigger than 9 but i either then have to select each digit single OR there is some function i didnt find so far.

is there a function to calculate the cross total (checksum)?

Kind regards
Patrick
B
23
S
8
G
1
Posts: 225
Reputation: 2,757

» Sun May 31, 2015 1:14 pm

Dividing by ten (as an int) gets the first number, Modulus gets the second.

int(Variable/10) + Variable%10
B
71
S
22
G
281
Posts: 3,842
Reputation: 154,886

» Sun May 31, 2015 1:51 pm

wow thanks well seems like school is to long ago
works for me!

Kind Regards
B
23
S
8
G
1
Posts: 225
Reputation: 2,757