Re: -dateWithTimeIntervalSinceNow: 64-bits may overflow
Re: -dateWithTimeIntervalSinceNow: 64-bits may overflow
- Subject: Re: -dateWithTimeIntervalSinceNow: 64-bits may overflow
- From: Sean McBride <email@hidden>
- Date: Wed, 12 Oct 2011 17:40:28 -0400
- Organization: Rogue Research Inc.
On Sat, 8 Oct 2011 21:09:15 -0700, Jerry Krinock said:
>Don't do this:
>
> -[NSDate dateWithTimeIntervalSinceNow:FLT_MAX] ;
>
>Expected result: A date far off into the future which will always behave
>as though it is later than or equal to any other date.
>
>No problem ever in 32-bit executable.
>
>In 64-bit, -[NSDate compare:] and -[NSDate laterDate:] still work as
>expected. But other methods may not. For example, -[NSConditionLock
>lockWhenCondition:beforeDate:] seems to think that such a "float max
>date" has already past and returns NO immediately, regardless of its
>'condition'.
>
>I filed a bug, 10256461, but am posting here because I suppose Apple may
>consider this to be a programming error and not a bug.
Strange since NSTimeInterval is double in both 32 and 64 bit. Why did you use FLT_MAX and not DBL_MAX? No doubt the latter would be even worse. :)
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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