# How do you use absolute value in coding?

#1

What is it and what is it used for?

#2

Absolute value is represent by the |#| (I don't know if it's different inn the app).

It's basically making the number positive if it isn't already.

#3

An absolute value is the opposite of the number.

For example, the absolute value of 3 is -3, anf the absolute value of 21 would be -21.
MATH LESSON- 9+10=21

#4

It is an operator that changes any number to a positive number.
Example: 234 will stay 234, but -765 will change to 765.

hope I was right

#5

Oh! I remember something like this in my math book! Thanks, @PopTart0219 @CreationsOfaNoob @LazyLizard what could I use it for in coding?

#6

Eeerrrrmmmâ€¦

Maybe if you have a negative number that changes, and you need to make it positive again.

#7

Technically incorrect; the real definition is the distance the number is from zero. :D

#8

What Gilbert said XD

I understood the concept but I fail at explaining and doing math. :3

#9

The distance a number is away from zero.

#10

I'm not sure. I haven't been able to code for months, so I can't really help you with that, I'm so sorry!

#11

Just to clarify: Absolute value is not the opposite of a number. It's the distance from 0 like rainbow chicken said.

Abs 21 = 21
Abs -21 = 21

#12

Yah I get it now, I just forgot the term. My question is, how can I use them in coding?

#13

A lot of things, but definitely the most important is distance. If you want to find the distance between 2 object's x positions, it's Abs(x1-x2).

#14

That isn't really correct, |-3| is 3 and the absolute value of 3 is three :D

#15

Woops!

Ignore that! XD

Maybe I should have used the wifi when typing. I almost always get wrapped up in not getting yelled at for using the data and just let my fingers fly!