More than 26 Digit Larger Data Size Integer for Swift

I am Converting numerical string to Int numbers in my Swift Playground in Xcode.

My calculation is getting more than 26 Digits...

e.g. "4444423533331235525555555"

I am getting error nil...

How to fix this?

My code look something like this:

Code Block
let ageString = "4444423533331235525555555"
let ageInt = Int(ageString)
print(ageInt ?? 0)

Replies

More than 26 Digit Larger Data Size Integer for Swift

I responded on the other thread you created for the same question.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"

let ageString = "4444423533331235525555555"

Eh, the age is way more than the age of universe…

age of universe (in years)
  15 000 000 000
even expressed in seconds:
  473 040 000 000 000 000
which is 10 000 000 times less
or in ms
473 040 000 000 000 000 000
still 10 000 times less.
So, your number is 10 times the age of universe measured in micro seconds…

So question, where do you need such large Int number ?

If that was just to know the limits of Swift, eskimo gave the answer again.

Note : Int.max =
9 223 372 036 854 775 807
473 040 000 000 000 000
That's 20 times the age of universe in seconds…

have a good day.