Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Absolute Value |x - y|



On 4 Dec 2004, at 19:16, Malte wrote:

i've been looking around trying to find a method that calculates the |absolute value| of a number.
Without success.
Does anyone know if such a function exists?

This is really a C programming task (and a trivial one at that) rather than a Cocoa problem.


For the specific case of |x-y| that you give in your subject line you can use:
absoluteValue = (x>y) ? x-y : y-x;
I'll leave it as an exercise to the reader to work out how to deal with more general cases.


	Nicko

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Absolute Value |x - y| (From: Malte <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.