# isolating a number from its place value

0 favourites
• 13 posts
From the Asset Store
Forgotten Place - Melodic ambiance, background music, Synth
• i am not sure about my translation [number value?] but what i mean is for example picking 6 from 657, not 600.

i hope my explanation is clear.

• California , Why ask that ?

To pick 6 from 657

it just takes some math ...

floor(657/100)

Here we go

You can remplace 657 by any other 3 numbers number !

• to know if something got lost in translation and help him in his own language.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• thanks Whiteclaws :)

• but does it solve the problem for 5 in 657, or for 7?

how can i eliminate tens or hundreds?

• by subtracting them? 657 - 600 = 57, 657 - 650 = 7

You could also put the numbers into a string, str(657) then pick the letter based on its position, and convert it back into a number int(mid(1,1)) would return 6.

• the numbers will not be predetermined. so, for substraction i think i must add another floor function etc.

or use your string solution :)

thanks

• i've taken Ethan's advice and used zeropad expression too and this one below solved my problem:

i used "left" and "mid" too of course.

• Why don't you convert the number to string and use mid(Text, Index, Length) to pull the current value.

Example:

Number = 657

mid(str(Number), 0, 1) would give you 6

mid(str(Number), 1, 1) would give you 5

mid(str(Number), 2, 1) would give you 7

• you are right. i didn't know that. but zeropad is still necessary i think.

• Think a bit , what would give us 600 ?

(Floor(657/100))*100

Then you just do

Floor((657-600)/10)

And you get the 5

Then you do

657-600-5*10=7

And you get

6,5,7

Math solves everything , just think a bit !

• Yes you are right too. Maybe thinking of simpler solutions is better than searching a magic wand (like an expression which can give me exactly what i want, i couldn't find one anyway :) ).

thanks all of you again.

• 13 posts