Re: How to implement float min(float x, ...) ?
Re: How to implement float min(float x, ...) ?
- Subject: Re: How to implement float min(float x, ...) ?
- From: Roland King <email@hidden>
- Date: Mon, 17 Nov 2008 16:18:43 +0800
it will work for simple types like float, but you need to deal with
figuring out you're at the end of the list.
ie you can call va_arg( xxx, float) and get a float, but you don't
know how many of them you have so you don't know where to stop.
You could use a defined nanf() value to show the end of your list
(similar to the way objective-C uses nil) I suppose, or else have
something like
min( int count, float x, .. ) where count denotes how many you have.
On Nov 17, 2008, at 3:38 PM, Oleg Krupnov wrote:
I apologize, this is plain old C, not Cocoa-specific question, but the
fastest way to get the answer.
I want to create a function that finds the minimum out of a
variable-length list of simple float arguments. In other words, I want
this function:
float min(float x, ...);
Can anyone suggest the implementation?
I have read this: http://developer.apple.com/qa/qa2005/qa1405.html
but it seems to address arguments of type "id", not sure it will work
for simple integral types like float.
Thanks!
_______________________________________________
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
_______________________________________________
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