Re: Can't divide integers ?
Re: Can't divide integers ?
- Subject: Re: Can't divide integers ?
- From: Scott Thompson <email@hidden>
- Date: Wed, 21 Jul 2004 15:33:38 -0500
On Jul 21, 2004, at 1:39 PM, Sscar Morales Vivs wrote:
>
Well, you'd need something like the following:
>
>
- (void)myMethod
>
{
>
unsigned a = 50;
>
unsigned b = 100;
>
>
float c = (float)a / (float)b;
>
>
...
>
}
>
>
Otherwise it does integer division, which for 50/100 equals 0.
You only really have to cast one integer or the other:
float c = (float) a / b;
or
float c = a / (float) b;
But doing both of them doesn't hurt anything.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.