Big Integer wrapping types

Swift doesn't have integer with size bigger than 64 bits, thus we have added new types to this library which wrap BigInt so that they can be used for separate serialization adapter in our SCALE codec library.

public struct Int128: Codable, Equatable { }
public struct Int256: Codable, Equatable { }
public struct Int512: Codable, Equatable { }
public struct UInt128: Codable, Equatable { }
public struct UInt256: Codable, Equatable { }
public struct UInt512: Codable, Equatable { }

Each of them also has same to and from Data set of methods, but also for convenience there are constructors to avoid extra BigInt construction.

let int256FromString = Int256("1234567890")
let int64: Int64 = 8
let int256FromInt8 = Int256(int64)

All of 128, 256, 512 unsigned and signed types allows you to instantiate object by providing any respectively unsigned or signed integers of lesser size, including BigInt wrapping ones.

Last updated