• 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: NSString floatValue issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString floatValue issue


  • Subject: Re: NSString floatValue issue
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Tue, 26 Feb 2008 19:12:05 +0100

As far as I know, there is no Math expression parser buit-in Cocoa. You will have to write your own evaluator to do this.

Le 26 févr. 08 à 18:55, C Sandeep a écrit :

Greetings,
I need to evaluate a NSString as a float value (represented by
NSNumber object). Here is my code snippet:

----
   NSString *str = @"28/5";
   NSNumber *nm = [NSNumber numberWithFloat:[str floatValue]];
   NSLog(@"number: %@", nm );
----

this results in:

----
number: 28.0
----

However, I was expecting 5.6 as the result. How do I achieve this ? Thanks.

- Sandeep
_______________________________________________

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


_______________________________________________

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


  • Follow-Ups:
    • Re: NSString floatValue issue
      • From: "Hamish Allan" <email@hidden>
References: 
 >NSString floatValue issue (From: "C Sandeep" <email@hidden>)

  • Prev by Date: Re: NSString floatValue issue
  • Next by Date: Re: NSString floatValue issue
  • Previous by thread: Re: NSString floatValue issue
  • Next by thread: Re: NSString floatValue issue
  • Index(es):
    • Date
    • Thread