• 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: NSNumberFormatter setExponentSymbol doing nothing (was Re: API to convert string to number?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNumberFormatter setExponentSymbol doing nothing (was Re: API to convert string to number?)


  • Subject: Re: NSNumberFormatter setExponentSymbol doing nothing (was Re: API to convert string to number?)
  • From: Michael Babin <email@hidden>
  • Date: Wed, 28 Feb 2007 17:24:29 -0600


On Feb 28, 2007, at 4:46 PM, E. Wing wrote:

So I'm still having problem with the exponent symbols. Calling
NSNumberFormatter's setExponentSymbol method seems to do nothing.

[snip]

Does this look like an Apple bug to anybody else. Below is a toy test
program. I'm on 10.4.8 and not using any backwards compatibility SDKs.

[snip]

#import <Foundation/Foundation.h>

int main(int argc, char* argv[])
{

   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];


[NSNumberFormatter setDefaultFormatterBehavior:NSNumberFormatterBehavior10_4];



float converted_value;
NSNumberFormatter* number_formatter = [[[NSNumberFormatter alloc]
init] autorelease];
NSLog(@"exponentSymbol (before): %@", [number_formatter exponentSymbol]);
[number_formatter setExponentSymbol:@"e"];
NSLog(@"exponentSymbol (after): %@", [number_formatter exponentSymbol]);
NSLog(@"groupingSeparator: %@", [number_formatter groupingSeparator]);
NSLog(@"groupingSize: %d", [number_formatter groupingSize]);



// NSString* my_string = @"1,000"; NSString* my_string = @"1e3";

	NSNumber* ns_number = [number_formatter numberFromString:my_string];
	if(nil == ns_number)
	{
		NSLog(@"numberFromString failed");
		[pool release];
		return 0;
	}
	converted_value = [ns_number floatValue];

	NSLog(@"converted_value is: %f", converted_value);

	[pool release];

	return 0;
}

Try it now. Read the overview section at the top of the NSNumberFormatter Class Reference to understand why.


--
Michael Babin email@hidden
Order N Development, LLC http://www.orderndev.com/
Goldfish Aquarium for Mac: http://www.lifeglobe.com/product/index.php? pltid=2&ref=OrderNDev



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: NSNumberFormatter setExponentSymbol doing nothing (was Re: API to convert string to number?)
      • From: "E. Wing" <email@hidden>
References: 
 >NSNumberFormatter setExponentSymbol doing nothing (was Re: API to convert string to number?) (From: "E. Wing" <email@hidden>)

  • Prev by Date: NSNumberFormatter setExponentSymbol doing nothing (was Re: API to convert string to number?)
  • Next by Date: Re: NSNumberFormatter setExponentSymbol doing nothing (was Re: API to convert string to number?)
  • Previous by thread: NSNumberFormatter setExponentSymbol doing nothing (was Re: API to convert string to number?)
  • Next by thread: Re: NSNumberFormatter setExponentSymbol doing nothing (was Re: API to convert string to number?)
  • Index(es):
    • Date
    • Thread