Using Objective-C signbit()

April 11, 2009 § Leave a comment

Using Objective-C Math function signbit() to determine logic flow. Here we use it on CLLocationManager to demonstrate its use.

The signbit() macro shall determine whether the sign of its argument value is negative. NaNs, zeros, and infinities have a sign bit.

The signbit() macro shall return a non-zero value if and only if the sign of its argument value is negative.

Horizontal Accuracy returns with +x or -x values. signbit() will return a non-zero value if the argument value is -.

// Horizontal coordinates
if (signbit(newlocation.horizontalAccuracy)) {
// run code when accuracy is negative
// negative accuracy refer to invalid or unavailable measurement
}
else {
// run code when accuracy is positive
// Corelocation return positive for North & East, negative for South and West
// If latitude gives “-” value, then print South as it is true, print North as it is false

myLatitudeDirection = signbit(newLocation.coordinate.latitude) ? stringLocation(@”South”) : stringLocation(@”North”);
myLongitudeDirection = signbit(newLocation.coordinate.longitude) ? stringLocation(@”West”) : stringLocation(@”East”);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading Using Objective-C signbit() at Web Builders.

meta

%d bloggers like this: