Re: unsigning NSNumber
Re: unsigning NSNumber
- Subject: Re: unsigning NSNumber
- From: Ron Fleckner <email@hidden>
- Date: Sat, 26 Jul 2008 20:30:38 +1000
On 22/07/2008, at 10:20 PM, Steven Hamilton wrote:
Hi folks,
Can anyone tell me the most efficient way to unsign a floatvalue in
an NSNumber?
Like change a -1.47 to 1.47 ?
Thanks
// Below reverses the sign of, in this case, a float
float y, x; y = x = -12.0;
y -= x * 2; // reverses the sign of x.
printf("y = %f\n", y); // y = 12.000000
I don't think there's a method on NSNumber which does it for you, so
obviously you'd need to extract the value from your NSNumber instance
and then use the new value in a new NSNumber.
HTH,
Ron
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden