Skip to content

Instantly share code, notes, and snippets.

View mortendahl's full-sized avatar

Morten Dahl mortendahl

View GitHub Profile
@JadenGeller
JadenGeller / Arbitrary Precision and Arbitrary Base Integers Example.swift
Last active September 30, 2023 00:48
Swift Arbitrary Precision, Arbitrary Base Integers
// Use an integer literal to instantiate
let a: BigInt = 23559821412349283
// Or use a string literal if you want to start with a number that is greater than IntMax
let b: BigInt = "123456789876543234567876543234567876543"
// Perform arithmetic operations
let c: BigInt = 123456 + 321 // -> 12777
let d = c / 100 // -> 127
let e = d << d // -> 12700000000......(127 zeros)