Re: IOS floating point performance
Re: IOS floating point performance
- Subject: Re: IOS floating point performance
- From: John McCall <email@hidden>
- Date: Thu, 08 Aug 2013 10:19:26 -0700
On Aug 8, 2013, at 6:37 AM, Scott Ribe <email@hidden> wrote:
> On Aug 8, 2013, at 6:37 AM, Roland King <email@hidden> wrote:
>> shouldn't do that as long as one uses the correct functions, ie sinf() and cosf().
>
> But */+- promote…
If all the operands to an operator are floats, the operation occurs in float, and
the type of the result will be float. However, if either type is double, the other
will be promoted, and the type of the result will be double. This is an easy
situation to get into because (a) the type of an unsuffixed floating-point literal
(e.g. 1.0 instead of 1.0f) is double and (b) while many of the math library calls
come in both float and double varieties, the double version usually has the
more obvious name.
C does permit the implementation to use a larger-precision type to compute
intermediate results within an expression. For example, if you compute
4.0f * someFloat + 7.0f * someOtherFloat, the implementation is allowed to
do this at a greater precision than float. But note that, when this is done,
it’s done *for better performance*, so that machines that don’t provide native
float support (like the x87 coprocessor) aren’t forced to round to float after
every operation. (Java permits something similar in the absence of ‘strictfp’.)
John.
_______________________________________________
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