Absolute Value

The absolute value of a number is it's magnitude, that is, how far it is away from 0. -5 and 5 both have the the absolute value of 5 because they are 5 "units" away from 0.

To further clarify, let's take example of someone who never takes a bath, which we will designate as 0. There are people on each side of him, one to the left and one to the right. To keep from being effected by the nauseous odor that 0 produces, each person has to be 10 feet away. We measure the left distance from 0 as a negative number and the right as a positive number.

Therefore, both people keep 10 feet away from 0 even though the actual numbers are represented differently.

Another example would be a bomb. It doesn't matter if your 10 feet to the right of the bomb (10) or 10 feet to the left of the bomb (-10), you're still going to get your legs blown off with the same force.

Abs() Function

Most game programming languages have the Abs() function to calculate the absolute value of a number.

SetFPS 60

Do
    Cls 0    
        Print " The Absolute Value of -10 is : " + Str$(Abs(-10))
    Sync
Loop

Links

Categories: Math
page tags: a absolute-value math value
page_revision: 11, last_edited: 1237714705|%e %b %Y, %H:%M %Z (%O ago)