0

I'm getting an error while trying to save a large number which is converted from a string value, I know its larger than CUnsignedLongLong but is there any method to solve this issue?

var strVal = "999999999999999999999"
var n : CUnsignedLongLong = CUnsignedLongLong(strVal)! // Getting error on this line 

fatal error: unexpectedly found nil while unwrapping an Optional value

Jan
  • 1,744
  • 3
  • 23
  • 38

1 Answers1

0

You got error because it is out of the bounds of CUnsignedLongLong. Max value of CUnsignedLongLong is 18,446,744,073,709,551,615 and you trying to assign value 999,999,999,999,999,999,999

Pavel Gatilov
  • 2,570
  • 2
  • 18
  • 31