Thursday, March 12, 2015 [Tweets] [Favorites]

The Minus Sign

Ole Begemann:

The default behavior of NSNumberFormatter is to use the hyphen-minus to format negative numbers. Considering that the class can be used not just for output formatting but also for parsing strings, this default makes sense. Almost every data interchange format (think JSON) uses the hyphen-minus to represent a minus sign.

But if you need to format negative numbers for display in your app, your text will look much more professional if you use the real minus sign. Fortunately, this is easy. All you need to do is create a string with the correct minus sign character and assign it to your number formatter’s minusSign property.

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment