• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can't divide integers ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Re: Can't divide integers ? (From: Óscar Morales Vivó <email@hidden>)

  • Prev by Date: Re: Problems with NSTextField and attributed strings
  • Next by Date: Re: Problems with NSTextField and attributed strings
  • Previous by thread: Re: Can't divide integers ?
  • Next by thread: Re: Using NSStream fails
  • Index(es):
    • Date
    • Thread