# Decimals and zeros being shown

Get help using Construct 2

### » Fri Aug 31, 2012 6:10 pm

B
16
S
4
G
1
Posts: 105
Reputation: 1,829

### » Fri Aug 31, 2012 7:40 pm

You could use the min() and max() expressions. Min(x, y) returns whichever value is smaller, so min(360, 428) would return 360. Opposite for max, so max(0,-5) would return 0. Other methods might work better depending on how you have it set up (I'm on my phone right know, can't check the file myself)
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

### » Sun Sep 02, 2012 1:00 am

Thanks a lot, man.

When I have to pick up the value typed in the TextBox, I add this expression allowing me to avoid values under and over the range from 0 to 360.

float(TextBox.Text)<=0? max(0,float(TextBox.Text)):min(360,float(TextBox.Text))

I've used the expression that you have posted before, with this '?' and ':' that allows to program a condition with code directly on a line.

And it works!!

I find that this world of expressions gives a lot of power and flexibility to Construct2.
B
16
S
4
G
1
Posts: 105
Reputation: 1,829

### » Sun Sep 02, 2012 1:11 am

You could also use the clamp expression:

clamp(float(TextBox.Text), 0, 360)

Will return 0 if the value is below 0 and 360 if it's above 360.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Previous