DexteR-Z Blogs

Wednesday, November 01, 2006

Magic of (-1/1)

While working on my pathfinding algos, I need my negative
value to be converted to a non-negative value.

Ah, I love the magic of (-1/1) or whatever math wiz called it,
it gives me the negative value of non-negative value and
vise versa multiply by it.

m = -10 * (-1/1); // gives me : 10
m = 10 * (-1/1); // gives me : -10

0 Comments:

Post a Comment

<< Home