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:
>>> from pyflex.numeric import Wad, Ray, RadConverting Wad, Ray, Rad to a str shows the numbers in a friendly format:
>>> Wad.from_number(1.2)
Wad(1200000000000000000)
>>> str(Wad.from_number(1.2))
'1.200000000000000000'Constructors will add a specific precision to a number eg. Wad(1) is not equal to 1 but to 10^18.
>>> Wad(10) == Wad.from_number(10)
False
>>> Wad(10) == Wad.from_number(10 * 1E-18)
TrueOperations: Addition, Subtraction, Division
Wad, Ray, and Rad can only perform addition, subtraction and division with another Wad, Ray, or Rad
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:
Conversion
Wad, Ray, and Rad all accept Wad, Ray, and Rad in the constructors. This is the canonical way to convert numbers:
During conversion (Rad to Ray/Wad or Ray to Wad) you may lose precision!
Last updated