# expression floor how use this?

Get help using Construct 2

### » Sat Dec 07, 2013 7:18 pm

how i can use this expression   i adding to variable 'floor(0.1)' and my variable still show 0 even if i add 20 times this number

I want something like that:
when i add to variable 0.9 i see 0 but when i add again i see 1
right?
B
109
S
25
G
43
Posts: 1,883
Reputation: 33,553

### » Sat Dec 07, 2013 7:40 pm

floor(0.1) = 0

so if you add 0 the variable stays the same.

you should probably just add 0.1 to your variable and when you want to use the variable anywhere, use floor(variable) so when variable is 0.9 it will return 0 and when the variable is 1 or 1.1 etcetera it will return 1.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Sat Dec 07, 2013 7:46 pm

floor() design is to round the value down.
ciel() designed to round the value up
round() designed to go to nearest.

so
floor(0.9) = 0
floor(1.8) = 1
floor(0.1 * 20) = 2
floor(0.1) * 20 = 0. Math done in brackets or functions are done first

ciel(0.9) = 1
ciel(1.8) = 2
ciel(0.1) = 1

round(0.9) = 1
round(1.8) = 2
round(0.1) = 0
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,013

### » Sat Dec 07, 2013 8:24 pm

@LittleStain   and @jayderyu can you check this? https://dl.dropboxusercontent.com/u/44710358/floor.capx

i must do something wrong because when i adding many times 0.1 to my variable, variable ALWAYS show 0 !delgado2013-12-07 20:38:25
B
109
S
25
G
43
Posts: 1,883
Reputation: 33,553

### » Sat Dec 07, 2013 10:33 pm

You're adding floor(0.1) or 0 to the variable so it won't ever change.

Just add 0.1 to your variable and set the text to floor(variable1) to do what you want.

B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

### » Sun Dec 08, 2013 1:44 am

R0j0hound got it :). I would consider R0j0 our community math export :)
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,013

### » Sun Dec 08, 2013 2:08 am

[QUOTE=jayderyu] R0j0hound got it :). I would consider R0j0 our community math export :)[/QUOTE]

expert*
B
97
S
35
G
29
Posts: 3,139
Reputation: 28,361

### » Sun Dec 08, 2013 4:41 am

Actually after re-reading the previous posts I realize that my post is redundant because LittleStain said the same thing before me. My apologies.
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

### » Sun Dec 08, 2013 8:38 am

@ROJOhound No apologies needed, sometimes the way it's written helps the reader more than the message itself.

Your comments and explanation of using math in Construct2 have helped many, myself included, so in my opinion a comment by you is never redundant.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775