# Multiply by -1 turns positive number into a negative

Just started using Construct 2? Post your questions here

### » 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!)

Code: Select all
`*-1`
B
41
S
12
G
14
Posts: 1,124
Reputation: 11,286

### » Sun Dec 11, 2016 8:08 pm

Dividing by zero opens up a portal to another dimension.
Prolly not try that one.
B
179
S
50
G
207
Posts: 8,719
Reputation: 128,306

### » 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
81
S
42
G
13
Posts: 268
Reputation: 13,660

### » 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,124
Reputation: 11,286

### » 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
81
S
42
G
13
Posts: 268
Reputation: 13,660

### » 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,124
Reputation: 11,286

### » Mon Dec 12, 2016 2:07 am

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

### » 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
415
S
248
G
92
Posts: 25,287
Reputation: 200,958

### » 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,124
Reputation: 11,286

### » Mon Dec 12, 2016 3:21 pm

-1 * -1 will give you 1... while -abs[-1 or 1] always will give you -1
B
110
S
24
G
18
Posts: 1,391
Reputation: 23,017

Next