GEB Docs
Search…
Numerics
GEB uses different numbers representing various levels of precision.
Type
Precision
Wad
1E-18
Ray
1E-27
Rad
1E-45
You can import them from pyflex:
1
>>> from pyflex.numeric import Wad, Ray, Rad
Copied!
Converting Wad, Ray, Rad to a str shows the numbers in a friendly format:
1
>>> Wad.from_number(1.2)
2
Wad(1200000000000000000)
3
>>> str(Wad.from_number(1.2))
4
'1.200000000000000000'
Copied!
Constructors will add a specific precision to a number eg. Wad(1) is not equal to 1 but to 10^18.
1
>>> Wad(10) == Wad.from_number(10)
2
False
3
>>> Wad(10) == Wad.from_number(10 * 1E-18)
4
True
Copied!

Operations: Addition, Subtraction, Division

Wad, Ray, and Rad can only perform addition, subtraction and division with another Wad, Ray, or Rad
1
>>> Rad(10) + Wad(10)
2
Traceback (most recent call last):
3
File "<stdin>", line 1, in <module>
4
File "/Users/georgekellerman/reflexer/pyflex/lib/python3.8/site-packages/pyflex/numeric.py", line 320, in __add__
5
raise ArithmeticError
6
ArithmeticError
7
>>> Ray(10) - Ray(5)
8
Ray(5)
9
>>> Rad(10) / Rad.from_number(2)
10
Rad(5)
11
>>>
12
Copied!

Operations: Multiplication

Wad, Ray, and Rad can be multiplied by any Wad, Ray, and Rad and int.
The result is the type of the first number:
1
>>> x = Wad.from_number(1.2) * Rad.from_number(1)
2
>>> type(x)
3
<class 'pyflex.numeric.Wad'>
4
>>> y = Rad.from_number(1) * Wad.from_number(1.2)
5
>>> type(y)
6
<class 'pyflex.numeric.Rad'>
Copied!

Conversion

Wad, Ray, and Rad all accept Wad, Ray, and Rad in the constructors. This is the canonical way to convert numbers:
1
>>> Rad(Wad(10))
2
Rad(10000000000000000000000000000)
Copied!
During conversion (Rad to Ray/Wad or Ray to Wad) you may lose precision!
1
>>> Wad(Rad(10))
2
Wad(0)
3
>>> Ray(Rad(20))
4
Ray(0)
Copied!
Last modified 8mo ago