• 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
more float rounding info
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

more float rounding info


  • Subject: more float rounding info
  • From: "Jay Rimalrick" <email@hidden>
  • Date: Sat, 29 Nov 2003 23:32:11 -0500

here is my problem upfront and personal:

float aFloat = 0.615;

int aInt = 0;

aFloat = aFloat * 100.0;

aFloat = round(aFloat); //roundf acts the same way as round for me

aInt = (int)aFloat; //just making sure the decimal values are gone

aFloat = aInt / 100.0;

NSLog(@"%f", aInt / 100.0); //this outputs 0.62

NSLog(@"%f", aFloat); //this outputs 0.619999



-this is very weird to me, any and all help is greatly appreciated





________________________________________________________________
Sent via the WebMail system at 1st.net
_______________________________________________
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.

  • Follow-Ups:
    • Re: more float rounding info
      • From: Kyle Moffett <email@hidden>
  • Prev by Date: Re: rounding a float
  • Next by Date: Re: rounding a float
  • Previous by thread: Re: NSIndexSet
  • Next by thread: Re: more float rounding info
  • Index(es):
    • Date
    • Thread