ID:154197
 
I was REALLY bad at math in school, so here's a simple question.

How do you find out how close one number another number?

-17 is how many numbers different from 31?

I have no clue how to do this.

And if there are any procs for this, point them out to me, please.
Thanks in advance.
Foomer wrote:
I was REALLY bad at math in school, so here's a simple question.

How do you find out how close one number another number?

-17 is how many numbers different from 31?

I have no clue how to do this.

That's absolute value: abs(x). That's equal to the distance of a number from 0, basically (i.e., it takes a number and chops off a negative sign, if there is one). So the distance between two numbers would be abs(x-y).

Lummox JR
Foomer wrote:
I was REALLY bad at math in school, so here's a simple question.

How do you find out how close one number another number?

-17 is how many numbers different from 31?

I have no clue how to do this.

And if there are any procs for this, point them out to me, please.
Thanks in advance.

Well, you just plug the numbers into a 3 dimensional distance formula:
dist = sqr((x1-x2)**2 + (y1-y2)**2 + (z1-z2)**2)
with the same y and z values for each point.

Heh, you can go that route, but it simplifies to dist = abs(x1-x2) on a one dimensional number line. The distance from -17 to 31 is 48.
Foomer wrote:
I was REALLY bad at math in school, so here's a simple question.

How do you find out how close one number another number?

-17 is how many numbers different from 31?

I have no clue how to do this.

And if there are any procs for this, point them out to me, please.
Thanks in advance.

It's called subtraction, and it's built right into BYOND! :-)

31 - (-17) = 48

probably best to use abs() so id doesn't matter which one is listed first:

proc/difference(num1, num2)
return abs(num1 - num2)
Footnote: If you're trying to figure out how many numbers are between two numbers, inclusive, do what everyone else said and add one. (in other words, 10 - 1 equals 9... but there are in fact 10 numbers from one to ten, of course).