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

Just started using Construct 2? Post your questions here

Post » 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)?


thanks for your help!
Kind regards
Patrick
B
19
S
7
G
1
Posts: 222
Reputation: 2,546

Post » 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
ImageImageImage
B
71
S
21
G
230
Posts: 3,687
Reputation: 128,845

Post » Sun May 31, 2015 1:51 pm

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

Kind Regards
B
19
S
7
G
1
Posts: 222
Reputation: 2,546


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests