Hexark Hexark - 1 year ago 119
Objective-C Question

ABS(A) and abs(int)

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!


Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download