Fixed Point
Last updated
Last updated
This library has been modified from cubit library by influenceth and adjusted to match with other fixed point implementations.
This API provides basic some operations for signed fixed point numbers. Fixed point numbers are represented as a struct with a magnitude and a sign.
The magnitude represents the absolute value of the number, and the sign indicates whether the number is positive or negative.
Orion supports currently these fixed point types:
Data type | dtype |
---|---|
Fixed
TraitFixed
trait defines the operations that can be performed on a fixed point.
function | description |
---|---|
FixedType
implements arithmetic and comparison traits. This allows you to perform basic arithmetic operations using the associated operators. (+
,+=
-
,-=
*
,*=
/
, /=
), as well as relational operators (>
, >=
,<
, <=
, ==
, !=
).
Q8.23
FP8x23
Q16.16
FP16x16
Q32.32
FP32x32
Q64.64
FP64x64
Constructs a new fixed point instance.
Creates a new fixed point instance with the specified unscaled magnitude and sign.
Creates a new fixed point instance from a felt252 value.
Returns the absolute value of the fixed point number.
Returns the smallest integer greater than or equal to the fixed point number.
Returns the value of e raised to the power of the fixed point number.
Returns the value of 2 raised to the power of the fixed point number.
Returns the largest integer less than or equal to the fixed point number.
Returns the natural logarithm of the fixed point number.
Returns the base-2 logarithm of the fixed point number.
Returns the base-10 logarithm of the fixed point number.
Returns the result of raising the fixed point number to the power of another fixed point number.
Rounds the fixed point number to the nearest whole number.
Returns the square root of the fixed point number.
Returns the arccosine (inverse of cosine) of the fixed point number.
Returns the arccosine (inverse of cosine) of the fixed point number faster with LUT.
Returns the arcsine (inverse of sine) of the fixed point number.
Returns the arcsine (inverse of sine) of the fixed point number faster with LUT.
Returns the arctangent (inverse of tangent) of the input fixed point number.
Returns the arctangent (inverse of tangent) of the input fixed point number faster with LUT.
Returns the cosine of the fixed point number.
Returns the cosine of the fixed point number fast with LUT.
Returns the sine of the fixed point number.
Returns the sine of the fixed point number faster with LUT.
Returns the tangent of the fixed point number.
Returns the tangent of the fixed point number faster with LUT.
Returns the value of the inverse hyperbolic cosine of the fixed point number.
Returns the value of the inverse hyperbolic sine of the fixed point number.
Returns the value of the inverse hyperbolic tangent of the fixed point number.
Returns the value of the hyperbolic cosine of the fixed point number.
Returns the value of the hyperbolic sine of the fixed point number.
Returns the value of the hyperbolic tangent of the fixed point number.
Returns the element-wise indication of the sign of the input fixed point number.
Returns the error function of the input fixed point number computed element-wise.