How would I go about manipulating massive numbers in swift?

I'm currently developing an iOS application that is required to do a vast number of scientific calculations as part of a series of simulations. These simulations are designed to emulated semiconductor device manufacturing, however I have ran into the issue that when I am attempting to do these calculations, the standard units used in the industry (e.g. number of atoms per unit volume of a silicon lattice) produce numbers that are far too big for UINT64 to handle. As a result I've been considering maybe converting from the standard cm^-3 units to m^-3. This would be a very odd unit however for most modern device simulations for most engineers and may lead to a loss in accuracy due to how small some calculated numbers are as well. Is there an alternative to this method I could use that is build into swift (say a Int128 that emulates a 128 bit integer?) or a library that someone could suggest? If not is my only option left to design a new type for a 128 bit number? Any help would be appreciated. I'm also open to use of Metal for this if it has any features that might allow for this. For clarification to, the numbers are on a magnitude of 5x10^22 cm^-3 and may get even larger.

Accepted Reply

Having spent all day looking for this information and getting incredibly frustrated, I did not come across the Float80 type until there now. I think it should do my job, but if anyone has any other suggestions or interesting comments for scientific computing I would love to hear

Replies

Having spent all day looking for this information and getting incredibly frustrated, I did not come across the Float80 type until there now. I think it should do my job, but if anyone has any other suggestions or interesting comments for scientific computing I would love to hear
IEEE has defined a quadruple precision floating point (aka Float128), but I've not seen it available in Swift libraries.

https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format