Multiply by -1 turns positive number into a negative

Just started using Construct 2? Post your questions here

Post » Sun Dec 11, 2016 7:23 pm

An incredibly simple trick, but to the maths inept of us, it's very useful, and might not be immediately obvious to someone who wants it (like me!) :lol:

Code: Select all
*-1
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Sun Dec 11, 2016 8:08 pm

Dividing by zero opens up a portal to another dimension.
Prolly not try that one.
Image ImageImage
B
169
S
50
G
173
Posts: 8,313
Reputation: 110,270

Post » Sun Dec 11, 2016 8:23 pm

In order to turn negatives into positives you can use absolute value.

abs(-20)
or
abs(20)

will give 20.
B
65
S
37
G
13
Posts: 240
Reputation: 12,703

Post » Sun Dec 11, 2016 8:42 pm

Unconnected wrote:In order to turn negatives into positives you can use absolute value.

abs(-20)
or
abs(20)

will give 20.

Can you use abs to turn a positive into a negative?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Sun Dec 11, 2016 8:46 pm

No. Abs means Absolute Value. There is no opposite for that, that I am aware of.

Multiplying by -1 seems good for that.
B
65
S
37
G
13
Posts: 240
Reputation: 12,703

Post » Sun Dec 11, 2016 11:36 pm

Unconnected wrote:No. Abs means Absolute Value. There is no opposite for that, that I am aware of.

Multiplying by -1 seems good for that.

That's what I thought, would like to know of any problems that could arise from doing it this way?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Mon Dec 12, 2016 2:07 am

That is the only way :P
B
27
S
6
G
5
Posts: 18
Reputation: 3,967

Post » Mon Dec 12, 2016 11:12 am

Zebbi wrote:Can you use abs to turn a positive into a negative?

-abs(x) will always return a negative number.
Scirra Founder
B
397
S
236
G
88
Posts: 24,389
Reputation: 194,448

Post » Mon Dec 12, 2016 1:35 pm

Ashley wrote:
Zebbi wrote:Can you use abs to turn a positive into a negative?

-abs(x) will always return a negative number.

Would that be more beneficial than using *-1?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Mon Dec 12, 2016 3:21 pm

-1 * -1 will give you 1... while -abs[-1 or 1] always will give you -1
Image
B
108
S
24
G
18
Posts: 1,372
Reputation: 22,817

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest