How can I use NumberFormatter() with numbers bigger than UInt64 in Swift?

I am using NumberFormatter() to format my number with down code, but NSNumber is unable to accept my number if it is bigger than UInt64, how can I solve the overflow issue here:

let formatter = NumberFormatter()
formatter.numberStyle = .none
formatter.usesGroupingSeparator = true
formatter.groupingSeparator = "."
formatter.groupingSize = 3

let number = 10100123521321985478329987147892245289547
let ff = NSNumber(value: number)

let output = formatter.string(from: ff) ?? "Error!"

Read more here:

Content Attribution

This content was originally published by Omid at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: