Skip to content

Commit 6af8d2b

Browse files
committed
Update README.md
1 parent e79707d commit 6af8d2b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,56 @@ Protocol-Oriented Number System in Pure Swift
99

1010
````swift
1111
import PONS // Let the fun begin!
12+
````
13+
14+
BigInt included. Enjoy unlimited!
1215

16+
````swift
1317
let bn = BigInt(1)<<64 + 1 // 18446744073709551617
1418
bn.asUInt64 // nil; bn > UIntMax.max
1519
(bn - 2).asUInt64 // 18446744073709551615 == UIntMax.max
1620
bn + bn // 36893488147419103234
1721
bn - bn // 0
1822
bn * bn // 340282366920938463500268095579187314689
1923
bn / bn // 1
24+
````
2025

26+
Rational (number type) is also included.
27+
28+
````
2129
let bq = BigInt(1).over(bn) // (1/18446744073709551617)
2230
bq + bq // (2/18446744073709551617)
2331
bq - bq // (0/1)
2432
bq * bq // (1/340282366920938463500268095579187314689)
2533
bq / bq // (1/1)
2634
bq.denominator == bn // true, of course!
2735
bq.reciprocal.numerator == bn // so is this
36+
````
37+
38+
Complex numbers. How can we live without them?
2839

40+
````swift
2941
let bz = bq + bq.i // ((1/18446744073709551617)+(1/18446744073709551617).i)
3042
bz + bz // ((2/18446744073709551617)+(2/18446744073709551617).i)
3143
bz - bz // ((0/1)+(0/1).i)
3244
bz * bz // ((0/1)+(2/340282366920938463500268095579187314689).i)
3345
bz / bz // ((1/1)+(0/1).i)
3446
````
3547

48+
Elementary functions are supported as static functions,
49+
By default it just converts to `Double`, let `Darwin` (or `Glibc` on Linux) do the work,
50+
and convertsit back by default.
51+
52+
TODO: rewrite elementary functions generically!
53+
54+
````swift
55+
Double.sqrt(-1) // sadly NaN
56+
Rational<BigUInt>.sqrt(bq) // yes, works with Rational, too!
57+
Complex.sqrt(-1) // happily i
58+
Complex.exp(Double.PI.i) // not exactly -1.0+0.0.i.
59+
Complex.log(-1) // Yes, πi
60+
````
61+
3662
## USAGE
3763

3864
### With Playground via Workspace

0 commit comments

Comments
 (0)