0

Whenever a value gets higher than 10^220, it gets stored as inf, is there any way around this? Is this true only for Double, which is what I am using in this case?

Gabriel
  • 37
  • 4

1 Answers1

0

You can use a bigger struct like Float80 that can store more bits.

There are Float32, Float64 and Float80 in Swift, where Float32 is just a typealias for Float and Float64 is one for Double.

Also, you can have a link list for storing almost infinite numbers of digits.

Mojtaba Hosseini
  • 95,414
  • 31
  • 268
  • 278
  • If I have a value, let say 'c', which I want to get larger before it reaches 'inf', if 'c' is actually a Double, could I implement the following to make it work: var c = Float80('The Double value which c represents') – Gabriel Sep 26 '21 at 21:37
  • @Gabriel don't use `Double` and or `Float80`. Use `Decimal` type. – Leo Dabus Sep 27 '21 at 01:14