0

I have a NSNumberFormatter and I would like to display currency as in a Billion, So if I have 1,000,000,000 $ I would like to display 1B $

I create NSNumberFormatter object and set multiplyer :

NSNumberFormatter * numberFormatter = [[NSNumberFormatter alloc]init];
[numberFormatter setMultiplier: @(1.0/1000000000)];

If I display multiplier as:

NSLog(@" NUMBER  %@", numberFormatter.multiplier); //  -->  NUMBER  1e-09

But if I put

NSLog(@"Formatter %@", [numberFormatter1 stringFromNumber:@(1225245041496000)]); // --> Formatter 0

It seams to me that multiplier round number but I don't know how to prevent this.

Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97
  • Similar question here, with several answers. Should be pretty straightforward to get to your goal: https://stackoverflow.com/questions/18267211/ios-convert-large-numbers-to-smaller-format – DonMag Jul 31 '17 at 13:07
  • Hi, I don't have problems with displaying right suffix but the fact that multiplayer is too small and it is rounded to zero. – Marko Zadravec Aug 01 '17 at 07:07

1 Answers1

1

Looks like you're exceeding the minimum value allowed for the multiplier. I can't find docs on it, but quick testing shows:

[numberFormatter setMultiplier: @(1.0 / 8388608.0)];

works fine, but

[numberFormatter setMultiplier: @(1.0 / 8388609.0)];

fails (string output is always "0").

So I don't think NSNumberFormatter is going to fit your needs.

DonMag
  • 69,424
  • 5
  • 50
  • 86