expression floor how use this?

Get help using Construct 2

Post » 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
110
S
27
G
47
Posts: 1,887
Reputation: 35,799

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

Post » 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,028

Post » 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
110
S
27
G
47
Posts: 1,887
Reputation: 35,799

Post » 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
92
S
32
G
109
Posts: 5,291
Reputation: 70,993

Post » 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,028

Post » Sun Dec 08, 2013 2:08 am

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


expert*
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » 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
92
S
32
G
109
Posts: 5,291
Reputation: 70,993

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


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 13 guests