Hexark - 8 months ago 76

Objective-C Question

I am baffled in the difference of this two in xcode, ABS(A) and abs(int). Cant seem to find ay explanation online as well. Which should I use? I am actually working on an accelerometer. Using ABS(A) and abs(int) gives me two different values. Using abs(int) would result in an inf value at times, while ABS(A) would give me a different value but never inf. Thanks!

http://www.switchonthecode.com/tutorials/iphone-tutorial-reading-the-accelerometer

Answer

`abs()`

works on int, meaning `abs(-10.123)`

would return `10`

, while `ABS()`

is a macro from `NSObjCRuntime.h`

which returns a value whose type is the type of the argument.