Re: Confused about floats
Re: Confused about floats
- Subject: Re: Confused about floats
- From: Kyle Sluder <email@hidden>
- Date: Tue, 5 Oct 2010 08:23:39 -0700
On Tue, Oct 5, 2010 at 8:20 AM, Kyle Sluder <email@hidden> wrote:
> The arithmetic conversion rules say that the integer literals will be
> promoted to the appropriate floating point type. So this is perfectly
> fine and does exactly what you expect:
P.S. The promotion doesn't only apply to literals but to other
expressions too. So your second casting example is unnecessary as
well. Compile this with -Wall -Werror to see that is is perfectly
valid C:
#include <stdio.h>
int main(int argc, char **argv) {
float x = 2.5;
int y = 5;
x += y;
printf("%f\n", x); // prints "7.500000"
return 0;
}
--Kyle Sluder
_______________________________________________
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