Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Absolute value of NSInteger

Tags:

objective-c

Referring to Convert to absolute value in Objective-C I'm wondering if there are functions for NS typedefed types. Or is abs(NSInteger) okay? Is it architecture-safe?

like image 769
user500 Avatar asked Sep 06 '11 14:09

user500


People also ask

How do I get absolute value in Objective C?

If you're using C++ or Objective-C++, you can bring in the <cmath> header and use std::abs() , which is templated for all the standard integer and floating-point types. Or you could use the ABS macro, which works on any number type.

What is abs function in swift?

The Anti-Lock braking system has two key functions. Foremost, is to stop the wheels from locking up when immediate brakes are applied and secondly to prevent the car from skidding on slippery roads. Furthermore, Swift's ABS has been accompanied by electronic brake force distribution system and brake assist.


1 Answers

Use ABS() macro, which is defined in NSObjCRuntime.h, it is architecture-safe.

like image 51
Davyd Geyl Avatar answered Oct 01 '22 18:10

Davyd Geyl