Re: Can't divide integers ?
Re: Can't divide integers ?
- Subject: Re: Can't divide integers ?
- From: Óscar Morales Vivó <email@hidden>
- Date: Wed, 21 Jul 2004 20:39:10 +0200
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.
It's a pretty annoying part of C if you ask me, but you get used to it.
On 21 Jul 2004, at 20:26, Eric Morand wrote:
Hi to all,
Here is a strange problem I have.
I want to divide two integers, giving a float.
Here is what I do :
- (void)myMethod
{
unsigned a = 50;
unsigned b = 100;
float c = a/b;
...
}
If I check in the debugger, c is equal to zero !!!
If I write :
- (void)myMethod
{
float a = 50;
float b = 100;
float c = a/b;
...
}
It works !!!
What does this mean ? Is it impossible to divide two integers ?
_______________________________________________
MacOSX-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/macosx-dev
_______________________________________________
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.