nsnumberformatter Questions

5

Solved

I am trying to have a number string with maximum 2 decimals precision, while rest decimals just trimmed off instead of rounding them up. For example: I have: 123456.9964 I want: 123456.99 -> J...
Scrounge asked 7/3, 2013 at 5:54

21

Solved

Is there a way to use NSNumberFormatter to get the 'th' 'st' 'nd' 'rd' number endings? EDIT: Looks like it does not exist. Here's what I'm using. +(NSString*)ordinalNumberFormat:(NSInteger)num{ ...
Chen asked 22/7, 2010 at 20:4

7

Solved

I don't understand how NSNumberFormatterPercentStyle works! Example: NSNumber *number = [NSNumber numberWithFloat:90.5]; NSNumberFormatter *percentageFormatter = [[[NSNumberFormatter alloc] init]...
Preoccupation asked 11/8, 2010 at 15:53

9

Solved

I'm trying to format currency values in an iOS app, and I'm using the current Locale settings on the device to use the appropriate currency formatting. In the simulator, everything seems to run fi...
Derma asked 7/1, 2018 at 10:58

7

Solved

I want to use a number formatter to generate my output, so the number is automatically formatted for the user's locale, but I want it to work like "%+.1f" does in printf(), that is always have a si...
Ful asked 4/1, 2013 at 1:9

5

Solved

If I do the following in Objective-C: NSString *result = [NSString stringWithFormat:@"%1.1f", -0.01]; It will give result @"-0.0" Does anybody know how I can force a result @"0.0" (without the ...
Crockett asked 10/6, 2012 at 14:15

4

Solved

I want to format my number into a currency string. These are the following cases 25.00 => $25 25.43 => $25.43 25.4 => $25.40 0.00 -> $0 Is there a way to do this in NSNumberFormatter...
Bernetta asked 10/3, 2014 at 13:56

0

I have a UITextField with a mask formatting my input to the BRL currency, so input 1700 from keyboard results in R$ 1.700,00 text, but since I need this value as double, NumberFormatter was used li...
Pierrepierrepont asked 22/5, 2021 at 18:57

1

Is this a bug when using maximumFractionDigits and maximumSignificantDigits together on NSNumberForamtter on iOS 8? NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; formatter.maxim...
Bearded asked 25/12, 2014 at 5:3

9

Solved

I have a number let’s say 0.00. When the user taps 1. We should have 0.01 When the user taps 2. We should display 0.12 When the user taps 3. We should display 1.23 When the user taps 4. We shoul...
Hellenize asked 21/4, 2015 at 20:57

2

Working on currency formatting, I've found an issue when trying to format Chilean pesos. Following this code: let priceFormatter = NumberFormatter() priceFormatter.locale = Locale(identifier: "e...
Irk asked 24/10, 2019 at 15:2

8

I want to format number to this: 123.234.234.234 from 123234234234 depends on what the user types into the text field. I don't want to manage currency, it's not about currency, it is about the user...
Cacophony asked 19/6, 2017 at 12:34

3

Solved

I have currently a string like this: "8,0" or "4,25" and I need to convert it to a Double, but how would I do that? Do I first replace the , with a .? I have looked at NSNumberFormatter but that r...
Attenweiler asked 22/1, 2016 at 9:6

6

can anybody help me with this: i need to implement UITextField for input number. This number should always be in decimal format with 4 places e.g. 12.3456 or 12.3400. So I created NSNumberFormatter...
Antwanantwerp asked 22/6, 2012 at 14:6

4

Solved

I am using NSNumberFormatter to get a currency value from a string and it works well. I use this code to do so: NSNumberFormatter *nf = [[NSNumberFormatter alloc] init]; [nf setNumberStyle:NSNum...
Zohar asked 20/9, 2012 at 23:36

6

Solved

I have an NSNumberFormatter which I'm trying to use to generate a whole number of GBP (£) from an NSNumber. I keep getting two decimal places regardless of which incantation I try. My code is: NSNu...
Grooms asked 25/7, 2011 at 7:49

7

Solved

I'm able to convert a particular NSNumber into currency using NSNUmberFormatter. Its showign $ symbol, numbers separated by "," etc. But I don't want to display cents. For example its displaying $...
Genevivegenevra asked 8/3, 2012 at 9:25

3

Solved

I'm using Swift let myDouble = 8.5 as Double let percentFormatter = NSNumberFormatter() percentFormatter.numberStyle = NSNumberFormatterStyle.PercentStyle percentFormatter.multiplier = 1.00 let ...
Bedstead asked 22/5, 2015 at 13:58

10

Solved

I am creating a budget app that allows the user to input their budget as well as transactions. I need to allow the user to enter both pence and pounds from separate text fields and they need to be ...
Aoristic asked 25/7, 2014 at 16:47

5

Solved

I want to get which is the decimal symbol set up on the device. Until now I was using this method: NSString *decimalSymbol; NSNumberFormatter *f = [[NSNumberFormatter alloc] init]; [f setNumberS...
Mainstay asked 22/3, 2011 at 20:52

7

Solved

Yes. You are right. Of Course this is a duplicate question. Before flag my question, please continue reading below. I want to round a float value, which is 56.6748939 to 56.7 56.45678 to 56.5 56...
Jeannettejeannie asked 2/5, 2013 at 7:46

4

Solved

Xcode 8.0 (8A218a) GM Target: iOS 10 (Swift 3) Consider the following code: let number = NSDecimalNumber(decimal: 22.4) let numberFormatter = NumberFormatter() numberFormatter.numberStyle = .cur...
Fallon asked 12/9, 2016 at 20:6

0

How can I generate cardinal numbers(One, Two, Three) using NumberFormatter in Swift using Locale settings. For example, I am able to convert 1 minute -> One minute using English Locale setting...

3

Solved

I am trying to get number(float value) from string with currency symbol. eg. from "¥1,234" to 1234 from "AU$3,456" to 3456 from "56.78€" to 56.78 I tried the following code but I got 0 as a re...
Mehalek asked 22/12, 2012 at 3:3

5

Solved

I tried to convert an NSString like "12000.54" into "12.000,54". I wrote an NSNumberFormatter instance. NSNumberFormatter *formatter = [[[NSNumberFormatter alloc] init] autorelease]; [formatter s...
Interwork asked 20/4, 2013 at 17:22

© 2022 - 2025 — McMap. All rights reserved.