softfloatpy package
Module contents
- class softfloatpy.TininessMode(value)
Bases:
IntFlagThe tininess detection modes.
BEFORE_ROUNDING: Detecting tininess before rounding.AFTER_ROUNDING: Detecting tininess after rounding.
- BEFORE_ROUNDING = 0
- AFTER_ROUNDING = 1
- class softfloatpy.RoundingMode(value)
Bases:
IntFlagThe rounding modes.
NEAR_EVEN: Rounding to nearest, with ties to even.NEAR_MAX_MAG: Rounding to nearest, with ties to maximum magnitude (away from zero).MIN_MAG: Rounding to minimum magnitude (toward zero).MIN: Rounding to minimum (down).MAX: Rounding to maximum (up).
- NEAR_EVEN = 0
- MIN_MAG = 1
- MIN = 2
- MAX = 3
- NEAR_MAX_MAG = 4
- class softfloatpy.ExceptionFlag(value)
Bases:
IntFlagThe floating-point exception flags.
INEXACT: The exception set if the rounded value is different from the mathematically exact result of the operation.UNDERFLOW: The exception set if the rounded value is tiny and inexact.OVERFLOW: The exception set if the absolute value of the rounded value is too large to be represented.INFINITE: The exception set if the result is infinite given finite operands.INVALID: The exception set if a finite or infinite result cannot be returned.
- INEXACT = 1
- UNDERFLOW = 2
- OVERFLOW = 4
- INFINITE = 8
- INVALID = 16
- class softfloatpy.UInt32
Bases:
objectA 32-bit unsigned integer.
The object is immutable.
The following operators are supported:
unary operators:
+,~.binary operators:
+,-,*,//,%,<<,>>,&,|,^,<,<=,>,>=,==,!=,+=,-=,*=,//=,%=,<<=,>>=,&=,|=,^=.
The following operators are unsupported:
unary operators:
-.binary operators:
**,/,**=,/=.
- classmethod from_bytes(cls, bytes src) UInt32
Creates a new instance from the specified byte sequence.
- Parameters:
src – The byte sequence representing the native data with big endian. The length must be 4.
- Returns:
A new instance created from the specified byte sequence.
- Raises:
ValueError – If the length of bytes is not 4.
- classmethod from_f128(cls, Float128 src, rounding_mode=None, bool exact=True) UInt32
Creates a new instance from the specified IEEE 754 binary128 floating point.
The result is the same as that of
f128_to_ui32().- Parameters:
src – The IEEE 754 binary128 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary128 floating point.
- classmethod from_f16(cls, Float16 src, rounding_mode=None, bool exact=True) UInt32
Creates a new instance from the specified IEEE 754 binary16 floating point.
The result is the same as that of
f16_to_ui32().- Parameters:
src – The IEEE 754 binary16 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary16 floating point.
- classmethod from_f32(cls, Float32 src, rounding_mode=None, bool exact=True) UInt32
Creates a new instance from the specified IEEE 754 binary32 floating point.
The result is the same as that of
f32_to_ui32().- Parameters:
src – The IEEE 754 binary32 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary32 floating point.
- classmethod from_f64(cls, Float64 src, rounding_mode=None, bool exact=True) UInt32
Creates a new instance from the specified IEEE 754 binary64 floating point.
The result is the same as that of
f64_to_ui32().- Parameters:
src – The IEEE 754 binary64 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary64 floating point.
- classmethod from_int(cls, src) UInt32
Creates a new instance from the specified integer.
- Parameters:
src – The integer from which a new instance is created.
- Returns:
A new instance created from the specified integer.
- classmethod size(cls) int
Returns the native data size in bits.
- Returns:
The native data size in bits, i.e. 32.
- to_bytes(self) bytes
Returns the native data as a byte sequence.
- Returns:
A byte sequence representing the native data with big endian. The length is 4.
- to_f128(self) Float128
Converts the 32-bit unsigned integer to an IEEE 754 binary128 floating point.
The result is the same as that of
ui32_to_f128().- Returns:
The IEEE 754 binary128 floating point.
- to_f16(self) Float16
Converts the 32-bit unsigned integer to an IEEE 754 binary16 floating point.
The result is the same as that of
ui32_to_f16().- Returns:
The IEEE 754 binary16 floating point.
- to_f32(self) Float32
Converts the 32-bit unsigned integer to an IEEE 754 binary32 floating point.
The result is the same as that of
ui32_to_f32().- Returns:
The IEEE 754 binary32 floating point.
- to_f64(self) Float64
Converts the 32-bit unsigned integer to an IEEE 754 binary64 floating point.
The result is the same as that of
ui32_to_f64().- Returns:
The IEEE 754 binary64 floating point.
- to_int(self)
Returns the native data as an integer.
- Returns:
An integer that represents the native data.
- class softfloatpy.UInt64
Bases:
objectA 64-bit unsigned integer.
The object is immutable.
The following operators are supported:
unary operators:
+,~.binary operators:
+,-,*,//,%,<<,>>,&,|,^,<,<=,>,>=,==,!=,+=,-=,*=,//=,%=,<<=,>>=,&=,|=,^=.
The following operators are unsupported:
unary operators:
-.binary operators:
**,/,**=,/=.
- classmethod from_bytes(cls, bytes src) UInt64
Creates a new instance from the specified byte sequence.
- Parameters:
src – The byte sequence representing the native data with big endian. The length must be 8.
- Returns:
A new instance created from the specified byte sequence.
- Raises:
ValueError – If the length of bytes is not 8.
- classmethod from_f128(cls, Float128 src, rounding_mode=None, bool exact=True) UInt64
Creates a new instance from the specified IEEE 754 binary128 floating point.
The result is the same as that of
f128_to_ui64().- Parameters:
src – The IEEE 754 binary128 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary128 floating point.
- classmethod from_f16(cls, Float16 src, rounding_mode=None, bool exact=True) UInt64
Creates a new instance from the specified IEEE 754 binary16 floating point.
The result is the same as that of
f16_to_ui64().- Parameters:
src – The IEEE 754 binary16 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary16 floating point.
- classmethod from_f32(cls, Float32 src, rounding_mode=None, bool exact=True) UInt64
Creates a new instance from the specified IEEE 754 binary32 floating point.
The result is the same as that of
f32_to_ui64().- Parameters:
src – The IEEE 754 binary32 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary32 floating point.
- classmethod from_f64(cls, Float64 src, rounding_mode=None, bool exact=True) UInt64
Creates a new instance from the specified IEEE 754 binary64 floating point.
The result is the same as that of
f64_to_ui64().- Parameters:
src – The IEEE 754 binary64 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary64 floating point.
- classmethod from_int(cls, src) UInt64
Creates a new instance from the specified integer.
- Parameters:
src – The integer from which a new instance is created.
- Returns:
A new instance created from the specified integer.
- classmethod size(cls) int
Returns the native data size in bits.
- Returns:
The native data size in bits, i.e. 64.
- to_bytes(self) bytes
Returns the native data as a byte sequence.
- Returns:
A byte sequence representing the native data with big endian. The length is 8.
- to_f128(self) Float128
Converts the 64-bit unsigned integer to an IEEE 754 binary128 floating point.
The result is the same as that of
ui64_to_f128().- Returns:
The IEEE 754 binary128 floating point.
- to_f16(self) Float16
Converts the 64-bit unsigned integer to an IEEE 754 binary16 floating point.
The result is the same as that of
ui64_to_f16().- Returns:
The IEEE 754 binary16 floating point.
- to_f32(self) Float32
Converts the 64-bit unsigned integer to an IEEE 754 binary32 floating point.
The result is the same as that of
ui64_to_f32().- Returns:
The IEEE 754 binary32 floating point.
- to_f64(self) Float64
Converts the 64-bit unsigned integer to an IEEE 754 binary64 floating point.
The result is the same as that of
ui64_to_f64().- Returns:
The IEEE 754 binary64 floating point.
- to_int(self)
Returns the native data as an integer.
- Returns:
An integer that represents the native data.
- class softfloatpy.Int32
Bases:
objectA 32-bit signed integer.
The object is immutable.
The following operators are supported:
unary operators:
+,-,~.binary operators:
+,-,*,//,%,<<,>>,&,|,^,<,<=,>,>=,==,!=,+=,-=,*=,//=,%=,<<=,>>=,&=,|=,^=.
The following operators are unsupported:
binary operators:
**,/,**=,/=.
- classmethod from_bytes(cls, bytes src) Int32
Creates a new instance from the specified byte sequence.
- Parameters:
src – The byte sequence representing the native data with big endian. The length must be 4.
- Returns:
A new instance created from the specified byte sequence.
- Raises:
ValueError – If the length of bytes is not 4.
- classmethod from_f128(cls, Float128 src, rounding_mode=None, bool exact=True) Int32
Creates a new instance from the specified IEEE 754 binary128 floating point.
The result is the same as that of
f128_to_i32().- Parameters:
src – The IEEE 754 binary128 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary128 floating point.
- classmethod from_f16(cls, Float16 src, rounding_mode=None, bool exact=True) Int32
Creates a new instance from the specified IEEE 754 binary16 floating point.
The result is the same as that of
f16_to_i32().- Parameters:
src – The IEEE 754 binary16 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary16 floating point.
- classmethod from_f32(cls, Float32 src, rounding_mode=None, bool exact=True) Int32
Creates a new instance from the specified IEEE 754 binary32 floating point.
The result is the same as that of
f32_to_i32().- Parameters:
src – The IEEE 754 binary32 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary32 floating point.
- classmethod from_f64(cls, Float64 src, rounding_mode=None, bool exact=True) Int32
Creates a new instance from the specified IEEE 754 binary64 floating point.
The result is the same as that of
f64_to_i32().- Parameters:
src – The IEEE 754 binary64 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary64 floating point.
- classmethod from_int(cls, src) Int32
Creates a new instance from the specified integer.
- Parameters:
src – The integer from which a new instance is created.
- Returns:
A new instance created from the specified integer.
- classmethod size(cls) int
Returns the native data size in bits.
- Returns:
The native data size in bits, i.e. 32.
- to_bytes(self) bytes
Returns the native data as a byte sequence.
- Returns:
A byte sequence representing the native data with big endian. The length is 4.
- to_f128(self) Float128
Converts the 32-bit signed integer to an IEEE 754 binary128 floating point.
The result is the same as that of
i32_to_f128().- Returns:
The IEEE 754 binary128 floating point.
- to_f16(self) Float16
Converts the 32-bit signed integer to an IEEE 754 binary16 floating point.
The result is the same as that of
i32_to_f16().- Returns:
The IEEE 754 binary16 floating point.
- to_f32(self) Float32
Converts the 32-bit signed integer to an IEEE 754 binary32 floating point.
The result is the same as that of
i32_to_f32().- Returns:
The IEEE 754 binary32 floating point.
- to_f64(self) Float64
Converts the 32-bit signed integer to an IEEE 754 binary64 floating point.
The result is the same as that of
i32_to_f64().- Returns:
The IEEE 754 binary64 floating point.
- to_int(self)
Returns the native data as an integer.
- Returns:
An integer that represents the native data.
- class softfloatpy.Int64
Bases:
objectA 64-bit signed integer.
The object is immutable.
The following operators are supported:
unary operators:
+,-,~.binary operators:
+,-,*,//,%,<<,>>,&,|,^,<,<=,>,>=,==,!=,+=,-=,*=,//=,%=,<<=,>>=,&=,|=,^=.
The following operators are unsupported:
binary operators:
**,/,**=,/=.
- classmethod from_bytes(cls, bytes src) Int64
Creates a new instance from the specified byte sequence.
- Parameters:
src – The byte sequence representing the native data with big endian. The length must be 8.
- Returns:
A new instance created from the specified byte sequence.
- Raises:
ValueError – If the length of bytes is not 8.
- classmethod from_f128(cls, Float128 src, rounding_mode=None, bool exact=True) Int64
Creates a new instance from the specified IEEE 754 binary128 floating point.
The result is the same as that of
f128_to_i64().- Parameters:
src – The IEEE 754 binary128 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary128 floating point.
- classmethod from_f16(cls, Float16 src, rounding_mode=None, bool exact=True) Int64
Creates a new instance from the specified IEEE 754 binary16 floating point.
The result is the same as that of
f16_to_i64().- Parameters:
src – The IEEE 754 binary16 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary16 floating point.
- classmethod from_f32(cls, Float32 src, rounding_mode=None, bool exact=True) Int64
Creates a new instance from the specified IEEE 754 binary32 floating point.
The result is the same as that of
f32_to_i64().- Parameters:
src – The IEEE 754 binary32 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary32 floating point.
- classmethod from_f64(cls, Float64 src, rounding_mode=None, bool exact=True) Int64
Creates a new instance from the specified IEEE 754 binary64 floating point.
The result is the same as that of
f64_to_i64().- Parameters:
src – The IEEE 754 binary64 floating point from which a new instance is created.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
A new instance created from the specified IEEE 754 binary64 floating point.
- classmethod from_int(cls, src) Int64
Creates a new instance from the specified integer.
- Parameters:
src – The integer from which a new instance is created.
- Returns:
A new instance created from the specified integer.
- classmethod size(cls) int
Returns the native data size in bits.
- Returns:
The native data size in bits, i.e. 64.
- to_bytes(self) bytes
Returns the native data as a byte sequence.
- Returns:
A byte sequence representing the native data with big endian. The length is 8.
- to_f128(self) Float128
Converts the 64-bit signed integer to an IEEE 754 binary128 floating point.
The result is the same as that of
i64_to_f128().- Returns:
The IEEE 754 binary128 floating point.
- to_f16(self) Float16
Converts the 64-bit signed integer to an IEEE 754 binary16 floating point.
The result is the same as that of
i64_to_f16().- Returns:
The IEEE 754 binary16 floating point.
- to_f32(self) Float32
Converts the 64-bit signed integer to an IEEE 754 binary32 floating point.
The result is the same as that of
i64_to_f32().- Returns:
The IEEE 754 binary32 floating point.
- to_f64(self) Float64
Converts the 64-bit signed integer to an IEEE 754 binary64 floating point.
The result is the same as that of
i64_to_f64().- Returns:
The IEEE 754 binary64 floating point.
- to_int(self)
Returns the native data as an integer.
- Returns:
An integer that represents the native data.
- class softfloatpy.BFloat16
Bases:
objectA 16-bit brain floating point.
The object is immutable.
No operators are supported.
- classmethod from_bytes(cls, bytes src) BFloat16
Creates a new instance from the specified byte sequence.
- Parameters:
src – The byte sequence representing the native data with big endian. The length must be 2.
- Returns:
A new instance created from the specified byte sequence.
- Raises:
ValueError – If the length of bytes is not 2.
- classmethod from_f32(cls, Float32 src) BFloat16
Creates a new instance from the specified IEEE 754 binary32 floating point.
The result is the same as that of
f32_to_bf16().- Parameters:
src – The IEEE 754 binary32 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary32 floating point.
- classmethod from_float(cls, double src) BFloat16
Creates a new instance from the specified floating point.
- Parameters:
src – The floating point from which a new instance is created.
- Returns:
A new instance created from the specified floating point.
- is_inf(self) bool
Tests if the 16-bit brain floating point is an infinity.
The result is the same as that of
bf16_is_inf().- Returns:
Trueif the floating point is an infinity,Falseotherwise.
- is_nan(self) bool
Tests if the 16-bit brain floating point is a NaN.
The result is the same as that of
bf16_is_nan().- Returns:
Trueif the floating point is a NaN,Falseotherwise.
- is_signaling_nan(self) bool
Tests if the 16-bit brain floating point is a signaling NaN.
The result is the same as that of
bf16_is_signaling_nan().- Returns:
Trueif the floating point is a signaling NaN,Falseotherwise.
- classmethod size(cls) int
Returns the native data size in bits.
- Returns:
The native data size in bits, i.e. 16.
- to_bytes(self) bytes
Returns the native data as a byte sequence.
- Returns:
A byte sequence representing the native data with big endian. The length is 2.
- to_f32(self) Float32
Converts the 16-bit brain floating point to an IEEE 754 binary32 floating point.
The result is the same as that of
bf16_to_f32().- Returns:
The IEEE 754 binary32 floating point.
- to_float(self) double
Returns the native data as a floating point.
- Returns:
A floating point that represents the native data.
- class softfloatpy.Float16
Bases:
objectAn IEEE 754 binary16 floating point.
The object is immutable.
The following operators are supported:
unary operators:
+,-.binary operators:
+,-,*,/,//,%,<,<=,>,>=,==,!=,+=,-=,*=,/=,//=,%=.
The following operators are unsupported:
unary operator:
~.binary operators:
<<,>>,&,|,^,**,<<=,>>=,&=,|=,^=,**=.
- classmethod add(cls, Float16 x, Float16 y) Float16
Adds the IEEE 754 binary16 floating points.
The result is the same as that of
f16_add().- Parameters:
x – The floating point to be added.
y – The floating point to add.
- Returns:
The resulted number (
x + y).
- classmethod div(cls, Float16 x, Float16 y) Float16
Divides the IEEE 754 binary16 floating points.
The result is the same as that of
f16_div().- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number (
x / y).
- classmethod eq(cls, Float16 x, Float16 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary16 floating points.
The result is the same as that of
f16_eq().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- classmethod eq_signaling(cls, Float16 x, Float16 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary16 floating points.
The invalid exception flag is set for any NaN input, not just for signaling NaNs.
The result is the same as that of
f16_eq_signaling().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- classmethod from_bytes(cls, bytes src) Float16
Creates a new instance from the specified byte sequence.
- Parameters:
src – The byte sequence representing the native data with big endian. The length must be 2.
- Returns:
A new instance created from the specified byte sequence.
- Raises:
ValueError – If the length of bytes is not 2.
- classmethod from_f128(cls, Float128 src) Float16
Creates a new instance from the specified IEEE 754 binary128 floating point.
The result is the same as that of
f128_to_f16().- Parameters:
src – The IEEE 754 binary128 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary128 floating point.
- classmethod from_f16(cls, Float16 src) Float16
Creates a new instance from the specified IEEE 754 binary16 floating point.
The result is a copy of the specified instance.
- Parameters:
src – The IEEE 754 binary16 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary16 floating point.
- classmethod from_f32(cls, Float32 src) Float16
Creates a new instance from the specified IEEE 754 binary32 floating point.
The result is the same as that of
f32_to_f16().- Parameters:
src – The IEEE 754 binary32 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary32 floating point.
- classmethod from_f64(cls, Float64 src) Float16
Creates a new instance from the specified IEEE 754 binary64 floating point.
The result is the same as that of
f64_to_f16().- Parameters:
src – The IEEE 754 binary64 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary64 floating point.
- classmethod from_float(cls, double src) Float16
Creates a new instance from the specified floating point.
- Parameters:
src – The floating point from which a new instance is created.
- Returns:
A new instance created from the specified floating point.
- classmethod from_i32(cls, Int32 src) Float16
Creates a new instance from the specified 32-bit signed integer.
The result is the same as that of
i32_to_f16().- Parameters:
src – The 32-bit signed integer from which a new instance is created.
- Returns:
A new instance created from the specified 32-bit signed integer.
- classmethod from_i64(cls, Int64 src) Float16
Creates a new instance from the specified 64-bit signed integer.
The result is the same as that of
i64_to_f16().- Parameters:
src – The 64-bit signed integer from which a new instance is created.
- Returns:
A new instance created from the specified 64-bit signed integer.
- classmethod from_ui32(cls, UInt32 src) Float16
Creates a new instance from the specified 32-bit unsigned integer.
The result is the same as that of
ui32_to_f16().- Parameters:
src – The 32-bit unsigned integer from which a new instance is created.
- Returns:
A new instance created from the specified 32-bit unsigned integer.
- classmethod from_ui64(cls, UInt64 src) Float16
Creates a new instance from the specified 64-bit unsigned integer.
The result is the same as that of
ui64_to_f16().- Parameters:
src – The 64-bit unsigned integer from which a new instance is created.
- Returns:
A new instance created from the specified 64-bit unsigned integer.
- is_inf(self) bool
Tests if the IEEE 754 binary16 floating point is an infinity.
The result is the same as that of
f16_is_inf().- Returns:
Trueif the floating point is an infinity,Falseotherwise.
- is_nan(self) bool
Tests if the IEEE 754 binary16 floating point is a NaN.
The result is the same as that of
f16_is_nan().- Returns:
Trueif the floating point is a NaN,Falseotherwise.
- is_signaling_nan(self) bool
Tests if the IEEE 754 binary16 floating point is a signaling NaN.
The result is the same as that of
f16_is_signaling_nan().- Returns:
Trueif the floating point is a signaling NaN,Falseotherwise.
- classmethod le(cls, Float16 x, Float16 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary16 floating points.
The result is the same as that of
f16_le().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- classmethod le_quiet(cls, Float16 x, Float16 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary16 floating points.
The invalid exception flag is not set for quiet NaNs.
The result is the same as that of
f16_le_quiet().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- classmethod lt(cls, Float16 x, Float16 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary16 floating points.
The result is the same as that of
f16_lt().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- classmethod lt_quiet(cls, Float16 x, Float16 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary16 floating points.
The invalid exception flag is not set for quiet NaNs.
The result is the same as that of
f16_lt_quiet().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- classmethod mul(cls, Float16 x, Float16 y) Float16
Multiplies the IEEE 754 binary16 floating points.
The result is the same as that of
f16_mul().- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
- Returns:
The resulted number (
x * y).
- classmethod mul_add(cls, Float16 x, Float16 y, Float16 z) Float16
Multiplies and Adds the IEEE 754 binary16 floating points.
The result is the same as that of
f16_mul_add().- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
z – The floating point to add.
- Returns:
The resulted number (
x * y + z).
- neg(self) Float16
Negates the IEEE 754 binary16 floating point.
The result is the same as that of
f16_neg().- Returns:
The resulted number (
-x).
- classmethod rem(cls, Float16 x, Float16 y) Float16
Calculates a remainder by dividing the IEEE 754 binary16 floating points.
The result is the same as that of
f16_rem().- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number (
x % y).
- round_to_int(self, rounding_mode=None, bool exact=True) Float16
Rounds the number.
The result is the same as that of
f16_round_to_int().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact rounding is unable.
- Returns:
The resulted integer.
- classmethod size(cls) int
Returns the native data size in bits.
- Returns:
The native data size in bits, i.e. 16.
- sqrt(self) Float16
Calculates a square root of the IEEE 754 binary16 floating point.
The result is the same as that of
f16_sqrt().- Returns:
The resulted number (
sqrt(x)).
- classmethod sub(cls, Float16 x, Float16 y) Float16
Subtracts the IEEE 754 binary16 floating points.
The result is the same as that of
f16_sub().- Parameters:
x – The floating point to be subtracted.
y – The floating point to subtract.
- Returns:
The resulted number (
x - y).
- to_bytes(self) bytes
Returns the native data as a byte sequence.
- Returns:
A byte sequence representing the native data with big endian. The length is 2.
- to_f128(self) Float128
Converts the IEEE 754 binary16 floating point to a binary128 floating point.
The result is the same as that of
f16_to_f128().- Returns:
The IEEE 754 binary128 floating point.
- to_f16(self) Float16
Converts the IEEE 754 binary16 floating point to a binary16 floating point.
The result is a copy.
- Returns:
The IEEE 754 binary16 floating point.
- to_f32(self) Float32
Converts the IEEE 754 binary16 floating point to a binary32 floating point.
The result is the same as that of
f16_to_f32().- Returns:
The IEEE 754 binary32 floating point.
- to_f64(self) Float64
Converts the IEEE 754 binary16 floating point to a binary64 floating point.
The result is the same as that of
f16_to_f64().- Returns:
The IEEE 754 binary64 floating point.
- to_float(self) double
Returns the native data as a floating point.
- Returns:
A floating point that represents the native data.
- to_i32(self, rounding_mode=None, bool exact=True) Int32
Converts the IEEE 754 binary16 floating point to a 32-bit signed integer.
The result is the same as that of
f16_to_i32().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit signed integer.
- to_i64(self, rounding_mode=None, bool exact=True) Int64
Converts the IEEE 754 binary16 floating point to a 64-bit signed integer.
The result is the same as that of
f16_to_i64().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit signed integer.
- to_ui32(self, rounding_mode=None, bool exact=True) UInt32
Converts the IEEE 754 binary16 floating point to a 32-bit unsigned integer.
The result is the same as that of
f16_to_ui32().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit unsigned integer.
- to_ui64(self, rounding_mode=None, bool exact=True) UInt64
Converts the IEEE 754 binary16 floating point to a 64-bit unsigned integer.
The result is the same as that of
f16_to_ui64().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit unsigned integer.
- class softfloatpy.Float32
Bases:
objectAn IEEE 754 binary32 floating point.
The object is immutable.
The following operators are supported:
unary operators:
+,-.binary operators:
+,-,*,/,//,%,<,<=,>,>=,==,!=,+=,-=,*=,/=,//=,%=.
The following operators are unsupported:
unary operator:
~.binary operators:
<<,>>,&,|,^,**,<<=,>>=,&=,|=,^=,**=.
- classmethod add(cls, Float32 x, Float32 y) Float32
Adds the IEEE 754 binary32 floating points.
The result is the same as that of
f32_add().- Parameters:
x – The floating point to be added.
y – The floating point to add.
- Returns:
The resulted number (
x + y).
- classmethod div(cls, Float32 x, Float32 y) Float32
Divides the IEEE 754 binary32 floating points.
The result is the same as that of
f32_div().- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number (
x / y).
- classmethod eq(cls, Float32 x, Float32 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary32 floating points.
The result is the same as that of
f32_eq().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- classmethod eq_signaling(cls, Float32 x, Float32 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary32 floating points.
The invalid exception flag is set for any NaN input, not just for signaling NaNs.
The result is the same as that of
f32_eq_signaling().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- classmethod from_bf16(cls, BFloat16 src) Float32
Creates a new instance from the 16-bit brain floating point.
The result is the same as that of
bf16_to_f32().- Parameters:
src – The 16-bit brain floating point from which a new instance is created.
- Returns:
A new instance created from the specified 16-bit brain floating point.
- classmethod from_bytes(cls, bytes src) Float32
Creates a new instance from the specified byte sequence.
- Parameters:
src – The byte sequence representing the native data with big endian. The length must be 4.
- Returns:
A new instance created from the specified byte sequence.
- Raises:
ValueError – If the length of bytes is not 4.
- classmethod from_f128(cls, Float128 src) Float32
Creates a new instance from the specified IEEE 754 binary128 floating point.
The result is the same as that of
f128_to_f32().- Parameters:
src – The IEEE 754 binary128 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary128 floating point.
- classmethod from_f16(cls, Float16 src) Float32
Creates a new instance from the specified IEEE 754 binary16 floating point.
The result is the same as that of
f16_to_f32().- Parameters:
src – The IEEE 754 binary16 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary16 floating point.
- classmethod from_f32(cls, Float32 src) Float32
Creates a new instance from the specified IEEE 754 binary32 floating point.
The result is a copy of the specified instance.
- Parameters:
src – The IEEE 754 binary32 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary32 floating point.
- classmethod from_f64(cls, Float64 src) Float32
Creates a new instance from the specified IEEE 754 binary64 floating point.
The result is the same as that of
f64_to_f32().- Parameters:
src – The IEEE 754 binary64 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary64 floating point.
- classmethod from_float(cls, double src) Float32
Creates a new instance from the specified floating point.
- Parameters:
src – The floating point from which a new instance is created.
- Returns:
A new instance created from the specified floating point.
- classmethod from_i32(cls, Int32 src) Float32
Creates a new instance from the specified 32-bit signed integer.
The result is the same as that of
i32_to_f32().- Parameters:
src – The 32-bit signed integer from which a new instance is created.
- Returns:
A new instance created from the specified 32-bit signed integer.
- classmethod from_i64(cls, Int64 src) Float32
Creates a new instance from the specified 64-bit signed integer.
The result is the same as that of
i64_to_f32().- Parameters:
src – The 64-bit signed integer from which a new instance is created.
- Returns:
A new instance created from the specified 64-bit signed integer.
- classmethod from_ui32(cls, UInt32 src) Float32
Creates a new instance from the specified 32-bit unsigned integer.
The result is the same as that of
ui32_to_f32().- Parameters:
src – The 32-bit unsigned integer from which a new instance is created.
- Returns:
A new instance created from the specified 32-bit unsigned integer.
- classmethod from_ui64(cls, UInt64 src) Float32
Creates a new instance from the specified 64-bit unsigned integer.
The result is the same as that of
ui64_to_f32().- Parameters:
src – The 64-bit unsigned integer from which a new instance is created.
- Returns:
A new instance created from the specified 64-bit unsigned integer.
- is_inf(self) bool
Tests if the IEEE 754 binary32 floating point is an infinity.
The result is the same as that of
f32_is_inf().- Returns:
Trueif the floating point is an infinity,Falseotherwise.
- is_nan(self) bool
Tests if the IEEE 754 binary32 floating point is a NaN.
The result is the same as that of
f32_is_nan().- Returns:
Trueif the floating point is a NaN,Falseotherwise.
- is_signaling_nan(self) bool
Tests if the IEEE 754 binary32 floating point is a signaling NaN.
The result is the same as that of
f32_is_signaling_nan().- Returns:
Trueif the floating point is a signaling NaN,Falseotherwise.
- classmethod le(cls, Float32 x, Float32 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary32 floating points.
The result is the same as that of
f32_le().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- classmethod le_quiet(cls, Float32 x, Float32 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary32 floating points.
The invalid exception flag is not set for quiet NaNs.
The result is the same as that of
f32_le_quiet().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- classmethod lt(cls, Float32 x, Float32 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary32 floating points.
The result is the same as that of
f32_lt().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- classmethod lt_quiet(cls, Float32 x, Float32 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary32 floating points.
The invalid exception flag is not set for quiet NaNs.
The result is the same as that of
f32_lt_quiet().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- classmethod mul(cls, Float32 x, Float32 y) Float32
Multiplies the IEEE 754 binary32 floating points.
The result is the same as that of
f32_mul().- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
- Returns:
The resulted number (
x * y).
- classmethod mul_add(cls, Float32 x, Float32 y, Float32 z) Float32
Multiplies and Adds the IEEE 754 binary32 floating points.
The result is the same as that of
f32_mul_add().- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
z – The floating point to add.
- Returns:
The resulted number (
x * y + z).
- neg(self) Float32
Negates the IEEE 754 binary32 floating point.
The result is the same as that of
f32_neg().- Returns:
The resulted number (
-x).
- classmethod rem(cls, Float32 x, Float32 y) Float32
Calculates a remainder by dividing the IEEE 754 binary32 floating points.
The result is the same as that of
f32_rem().- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number (
x % y).
- round_to_int(self, rounding_mode=None, bool exact=True) Float32
Rounds the number.
The result is the same as that of
f32_round_to_int().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact rounding is unable.
- Returns:
The resulted integer.
- classmethod size(cls) int
Returns the native data size in bits.
- Returns:
The native data size in bits, i.e. 32.
- sqrt(self) Float32
Calculates a square root of the IEEE 754 binary32 floating point.
The result is the same as that of
f32_sqrt().- Returns:
The resulted number (
sqrt(x)).
- classmethod sub(cls, Float32 x, Float32 y) Float32
Subtracts the IEEE 754 binary32 floating points.
The result is the same as that of
f32_sub().- Parameters:
x – The floating point to be subtracted.
y – The floating point to subtract.
- Returns:
The resulted number (
x - y).
- to_bf16(self) BFloat16
Converts the IEEE 754 binary32 floating point to a 16-bit brain floating point.
The result is the same as that of
f32_to_bf16().- Returns:
The 16-bit brain floating point.
- to_bytes(self) bytes
Returns the native data as a byte sequence.
- Returns:
A byte sequence representing the native data with big endian. The length is 4.
- to_f128(self) Float128
Converts the IEEE 754 binary32 floating point to a binary128 floating point.
The result is the same as that of
f32_to_f128().- Returns:
The IEEE 754 binary128 floating point.
- to_f16(self) Float16
Converts the IEEE 754 binary32 floating point to a binary16 floating point.
The result is the same as that of
f32_to_f16().- Returns:
The IEEE 754 binary16 floating point.
- to_f32(self) Float32
Converts the IEEE 754 binary32 floating point to a binary32 floating point.
The result is a copy.
- Returns:
The IEEE 754 binary32 floating point.
- to_f64(self) Float64
Converts the IEEE 754 binary32 floating point to a binary64 floating point.
The result is the same as that of
f32_to_f64().- Returns:
The IEEE 754 binary64 floating point.
- to_float(self) double
Returns the native data as a floating point.
- Returns:
A floating point that represents the native data.
- to_i32(self, rounding_mode=None, bool exact=True) Int32
Converts the IEEE 754 binary32 floating point to a 32-bit signed integer.
The result is the same as that of
f32_to_i32().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit signed integer.
- to_i64(self, rounding_mode=None, bool exact=True) Int64
Converts the IEEE 754 binary32 floating point to a 64-bit signed integer.
The result is the same as that of
f32_to_i64().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit signed integer.
- to_ui32(self, rounding_mode=None, bool exact=True) UInt32
Converts the IEEE 754 binary32 floating point to a 32-bit unsigned integer.
The result is the same as that of
f32_to_ui32().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit unsigned integer.
- to_ui64(self, rounding_mode=None, bool exact=True) UInt64
Converts the IEEE 754 binary32 floating point to a 64-bit unsigned integer.
The result is the same as that of
f32_to_ui64().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit unsigned integer.
- class softfloatpy.Float64
Bases:
objectAn IEEE 754 binary64 floating point.
The object is immutable.
The following operators are supported:
unary operators:
+,-.binary operators:
+,-,*,/,//,%,<,<=,>,>=,==,!=,+=,-=,*=,/=,//=,%=.
The following operators are unsupported:
unary operator:
~.binary operators:
<<,>>,&,|,^,**,<<=,>>=,&=,|=,^=,**=.
- classmethod add(cls, Float64 x, Float64 y) Float64
Adds the IEEE 754 binary64 floating points.
The result is the same as that of
f64_add().- Parameters:
x – The floating point to be added.
y – The floating point to add.
- Returns:
The resulted number (
x + y).
- classmethod div(cls, Float64 x, Float64 y) Float64
Divides the IEEE 754 binary64 floating points.
The result is the same as that of
f64_div().- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number (
x / y).
- classmethod eq(cls, Float64 x, Float64 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary64 floating points.
The result is the same as that of
f64_eq().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- classmethod eq_signaling(cls, Float64 x, Float64 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary64 floating points.
The invalid exception flag is set for any NaN input, not just for signaling NaNs.
The result is the same as that of
f64_eq_signaling().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- classmethod from_bytes(cls, bytes src) Float64
Creates a new instance from the specified byte sequence.
- Parameters:
src – The byte sequence representing the native data with big endian. The length must be 8.
- Returns:
A new instance created from the specified byte sequence.
- Raises:
ValueError – If the length of bytes is not 8.
- classmethod from_f128(cls, Float128 src) Float64
Creates a new instance from the specified IEEE 754 binary128 floating point.
The result is the same as that of
f128_to_f64().- Parameters:
src – The IEEE 754 binary128 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary128 floating point.
- classmethod from_f16(cls, Float16 src) Float64
Creates a new instance from the specified IEEE 754 binary16 floating point.
The result is the same as that of
f16_to_f64().- Parameters:
src – The IEEE 754 binary16 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary16 floating point.
- classmethod from_f32(cls, Float32 src) Float64
Creates a new instance from the specified IEEE 754 binary32 floating point.
The result is the same as that of
f32_to_f64().- Parameters:
src – The IEEE 754 binary32 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary32 floating point.
- classmethod from_f64(cls, Float64 src) Float64
Creates a new instance from the specified IEEE 754 binary64 floating point.
The result is a copy of the specified instance.
- Parameters:
src – The IEEE 754 binary64 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary64 floating point.
- classmethod from_float(cls, double src) Float64
Creates a new instance from the specified floating point.
- Parameters:
src – The floating point from which a new instance is created.
- Returns:
A new instance created from the specified floating point.
- classmethod from_i32(cls, Int32 src) Float64
Creates a new instance from the specified 32-bit signed integer.
The result is the same as that of
i32_to_f64().- Parameters:
src – The 32-bit signed integer from which a new instance is created.
- Returns:
A new instance created from the specified 32-bit signed integer.
- classmethod from_i64(cls, Int64 src) Float64
Creates a new instance from the specified 64-bit signed integer.
The result is the same as that of
i64_to_f64().- Parameters:
src – The 64-bit signed integer from which a new instance is created.
- Returns:
A new instance created from the specified 64-bit signed integer.
- classmethod from_ui32(cls, UInt32 src) Float64
Creates a new instance from the specified 32-bit unsigned integer.
The result is the same as that of
ui32_to_f64().- Parameters:
src – The 32-bit unsigned integer from which a new instance is created.
- Returns:
A new instance created from the specified 32-bit unsigned integer.
- classmethod from_ui64(cls, UInt64 src) Float64
Creates a new instance from the specified 64-bit unsigned integer.
The result is the same as that of
ui64_to_f64().- Parameters:
src – The 64-bit unsigned integer from which a new instance is created.
- Returns:
A new instance created from the specified 64-bit unsigned integer.
- is_inf(self) bool
Tests if the IEEE 754 binary64 floating point is an infinity.
The result is the same as that of
f64_is_inf().- Returns:
Trueif the floating point is an infinity,Falseotherwise.
- is_nan(self) bool
Tests if the IEEE 754 binary64 floating point is a NaN.
The result is the same as that of
f64_is_nan().- Returns:
Trueif the floating point is a NaN,Falseotherwise.
- is_signaling_nan(self) bool
Tests if the IEEE 754 binary64 floating point is a signaling NaN.
The result is the same as that of
f64_is_signaling_nan().- Returns:
Trueif the floating point is a signaling NaN,Falseotherwise.
- classmethod le(cls, Float64 x, Float64 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary64 floating points.
The result is the same as that of
f64_le().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- classmethod le_quiet(cls, Float64 x, Float64 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary64 floating points.
The invalid exception flag is not set for quiet NaNs.
The result is the same as that of
f64_le_quiet().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- classmethod lt(cls, Float64 x, Float64 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary64 floating points.
The result is the same as that of
f64_lt().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- classmethod lt_quiet(cls, Float64 x, Float64 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary64 floating points.
The invalid exception flag is not set for quiet NaNs.
The result is the same as that of
f64_lt_quiet().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- classmethod mul(cls, Float64 x, Float64 y) Float64
Multiplies the IEEE 754 binary64 floating points.
The result is the same as that of
f64_mul().- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
- Returns:
The resulted number (
x * y).
- classmethod mul_add(cls, Float64 x, Float64 y, Float64 z) Float64
Multiplies and Adds the IEEE 754 binary64 floating points.
The result is the same as that of
f64_mul_add().- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
z – The floating point to add.
- Returns:
The resulted number (
x * y + z).
- neg(self) Float64
Negates the IEEE 754 binary64 floating point.
The result is the same as that of
f64_neg().- Returns:
The resulted number (
-x).
- classmethod rem(cls, Float64 x, Float64 y) Float64
Calculates a remainder by dividing the IEEE 754 binary64 floating points.
The result is the same as that of
f64_rem().- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number (
x % y).
- round_to_int(self, rounding_mode=None, bool exact=True) Float64
Rounds the number.
The result is the same as that of
f64_round_to_int().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact rounding is unable.
- Returns:
The resulted integer.
- classmethod size(cls) int
Returns the native data size in bits.
- Returns:
The native data size in bits, i.e. 64.
- sqrt(self) Float64
Calculates a square root of the IEEE 754 binary64 floating point.
The result is the same as that of
f64_sqrt().- Returns:
The resulted number (
sqrt(x)).
- classmethod sub(cls, Float64 x, Float64 y) Float64
Subtracts the IEEE 754 binary64 floating points.
The result is the same as that of
f64_sub().- Parameters:
x – The floating point to be subtracted.
y – The floating point to subtract.
- Returns:
The resulted number (
x - y).
- to_bytes(self) bytes
Returns the native data as a byte sequence.
- Returns:
A byte sequence representing the native data with big endian. The length is 8.
- to_f128(self) Float128
Converts the IEEE 754 binary64 floating point to a binary128 floating point.
The result is the same as that of
f64_to_f128().- Returns:
The IEEE 754 binary128 floating point.
- to_f16(self) Float16
Converts the IEEE 754 binary64 floating point to a binary16 floating point.
The result is the same as that of
f64_to_f16().- Returns:
The IEEE 754 binary16 floating point.
- to_f32(self) Float32
Converts the IEEE 754 binary64 floating point to a binary32 floating point.
The result is the same as that of
f64_to_f32().- Returns:
The IEEE 754 binary32 floating point.
- to_f64(self) Float64
Converts the IEEE 754 binary64 floating point to a binary64 floating point.
The result is a copy.
- Returns:
The IEEE 754 binary64 floating point.
- to_float(self) double
Returns the native data as a floating point.
- Returns:
A floating point that represents the native data.
- to_i32(self, rounding_mode=None, bool exact=True) Int32
Converts the IEEE 754 binary64 floating point to a 32-bit signed integer.
The result is the same as that of
f64_to_i32().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit signed integer.
- to_i64(self, rounding_mode=None, bool exact=True) Int64
Converts the IEEE 754 binary64 floating point to a 64-bit signed integer.
The result is the same as that of
f64_to_i64().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit signed integer.
- to_ui32(self, rounding_mode=None, bool exact=True) UInt32
Converts the IEEE 754 binary64 floating point to a 32-bit unsigned integer.
The result is the same as that of
f64_to_ui32().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit unsigned integer.
- to_ui64(self, rounding_mode=None, bool exact=True) UInt64
Converts the IEEE 754 binary64 floating point to a 64-bit unsigned integer.
The result is the same as that of
f64_to_ui64().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit unsigned integer.
- class softfloatpy.Float128
Bases:
objectAn IEEE 754 binary128 floating point.
The object is immutable.
The following operators are supported:
unary operators:
+,-.binary operators:
+,-,*,/,//,%,<,<=,>,>=,==,!=,+=,-=,*=,/=,//=,%=.
The following operators are unsupported:
unary operator:
~.binary operators:
<<,>>,&,|,^,**,<<=,>>=,&=,|=,^=,**=.
Note
Currently, cannot represent the exact number as a string if the number is unable to be expressed as an IEEE 754 binary64 floating point.
- classmethod add(cls, Float128 x, Float128 y) Float128
Adds the IEEE 754 binary128 floating points.
The result is the same as that of
f128_add().- Parameters:
x – The floating point to be added.
y – The floating point to add.
- Returns:
The resulted number (
x + y).
- classmethod div(cls, Float128 x, Float128 y) Float128
Divides the IEEE 754 binary128 floating points.
The result is the same as that of
f128_div().- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number (
x / y).
- classmethod eq(cls, Float128 x, Float128 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary128 floating points.
The result is the same as that of
f128_eq().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- classmethod eq_signaling(cls, Float128 x, Float128 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary128 floating points.
The invalid exception flag is set for any NaN input, not just for signaling NaNs.
The result is the same as that of
f128_eq_signaling().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- classmethod from_bytes(cls, bytes src) Float128
Creates a new instance from the specified byte sequence.
- Parameters:
src – The byte sequence representing the native data with big endian. The length must be 16.
- Returns:
A new instance created from the specified byte sequence.
- Raises:
ValueError – If the length of bytes is not 16.
- classmethod from_f128(cls, Float128 src) Float128
Creates a new instance from the specified IEEE 754 binary128 floating point.
The result is a copy of the specified instance.
- Parameters:
src – The IEEE 754 binary128 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary128 floating point.
- classmethod from_f16(cls, Float16 src) Float128
Creates a new instance from the specified IEEE 754 binary16 floating point.
The result is the same as that of
f16_to_f128().- Parameters:
src – The IEEE 754 binary16 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary16 floating point.
- classmethod from_f32(cls, Float32 src) Float128
Creates a new instance from the specified IEEE 754 binary32 floating point.
The result is the same as that of
f32_to_f128().- Parameters:
src – The IEEE 754 binary32 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary32 floating point.
- classmethod from_f64(cls, Float64 src) Float128
Creates a new instance from the specified IEEE 754 binary64 floating point.
The result is the same as that of
f64_to_f128().- Parameters:
src – The IEEE 754 binary64 floating point from which a new instance is created.
- Returns:
A new instance created from the specified IEEE 754 binary64 floating point.
- classmethod from_float(cls, double src) Float128
Creates a new instance from the specified floating point.
- Parameters:
src – The floating point from which a new instance is created.
- Returns:
A new instance created from the specified floating point.
Note
Cannot create an instance with a number that an IEEE 754 binary64 floating point is unable to express.
- classmethod from_i32(cls, Int32 src) Float128
Creates a new instance from the specified 32-bit signed integer.
The result is the same as that of
i32_to_f128().- Parameters:
src – The 32-bit signed integer from which a new instance is created.
- Returns:
A new instance created from the specified 32-bit signed integer.
- classmethod from_i64(cls, Int64 src) Float128
Creates a new instance from the specified 64-bit signed integer.
The result is the same as that of
i64_to_f128().- Parameters:
src – The 64-bit signed integer from which a new instance is created.
- Returns:
A new instance created from the specified 64-bit signed integer.
- classmethod from_ui32(cls, UInt32 src) Float128
Creates a new instance from the specified 32-bit unsigned integer.
The result is the same as that of
ui32_to_f128().- Parameters:
src – The 32-bit unsigned integer from which a new instance is created.
- Returns:
A new instance created from the specified 32-bit unsigned integer.
- classmethod from_ui64(cls, UInt64 src) Float128
Creates a new instance from the specified 64-bit unsigned integer.
The result is the same as that of
ui64_to_f128().- Parameters:
src – The 64-bit unsigned integer from which a new instance is created.
- Returns:
A new instance created from the specified 64-bit unsigned integer.
- is_inf(self) bool
Tests if the IEEE 754 binary128 floating point is an infinity.
The result is the same as that of
f128_is_inf().- Returns:
Trueif the floating point is an infinity,Falseotherwise.
- is_nan(self) bool
Tests if the IEEE 754 binary128 floating point is a NaN.
The result is the same as that of
f128_is_nan().- Returns:
Trueif the floating point is a NaN,Falseotherwise.
- is_signaling_nan(self) bool
Tests if the IEEE 754 binary128 floating point is a signaling NaN.
The result is the same as that of
f128_is_signaling_nan().- Returns:
Trueif the floating point is a signaling NaN,Falseotherwise.
- classmethod le(cls, Float128 x, Float128 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary128 floating points.
The result is the same as that of
f128_le().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- classmethod le_quiet(cls, Float128 x, Float128 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary128 floating points.
The invalid exception flag is not set for quiet NaNs.
The result is the same as that of
f128_le_quiet().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- classmethod lt(cls, Float128 x, Float128 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary128 floating points.
The result is the same as that of
f128_lt().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- classmethod lt_quiet(cls, Float128 x, Float128 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary128 floating points.
The invalid exception flag is not set for quiet NaNs.
The result is the same as that of
f128_lt_quiet().- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- classmethod mul(cls, Float128 x, Float128 y) Float128
Multiplies the IEEE 754 binary128 floating points.
The result is the same as that of
f128_mul().- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
- Returns:
The resulted number (
x * y).
- classmethod mul_add(cls, Float128 x, Float128 y, Float128 z) Float128
Multiplies and Adds the IEEE 754 binary128 floating points.
The result is the same as that of
f128_mul_add().- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
z – The floating point to add.
- Returns:
The resulted number (
x * y + z).
- neg(self) Float128
Negates the IEEE 754 binary128 floating point.
The result is the same as that of
f128_neg().- Returns:
The resulted number (
-x).
- classmethod rem(cls, Float128 x, Float128 y) Float128
Calculates a remainder by dividing the IEEE 754 binary128 floating points.
The result is the same as that of
f128_rem().- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number (
x % y).
- round_to_int(self, rounding_mode=None, bool exact=True) Float128
Rounds the number.
The result is the same as that of
f128_round_to_int().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact rounding is unable.
- Returns:
The resulted integer.
- classmethod size(cls) int
Returns the native data size in bits.
- Returns:
The native data size in bits, i.e. 128.
- sqrt(self) Float128
Calculates a square root of the IEEE 754 binary128 floating point.
The result is the same as that of
f128_sqrt().- Returns:
The resulted number (
sqrt(x)).
- classmethod sub(cls, Float128 x, Float128 y) Float128
Subtracts the IEEE 754 binary128 floating points.
The result is the same as that of
f128_sub().- Parameters:
x – The floating point to be subtracted.
y – The floating point to subtract.
- Returns:
The resulted number (
x - y).
- to_bytes(self) bytes
Returns the native data as a byte sequence.
- Returns:
A byte sequence representing the native data with big endian. The length is 16.
- to_f128(self) Float128
Converts the IEEE 754 binary128 floating point to a binary128 floating point.
The result is a copy.
- Returns:
The IEEE 754 binary128 floating point.
- to_f16(self) Float16
Converts the IEEE 754 binary128 floating point to a binary16 floating point.
The result is the same as that of
f128_to_f16().- Returns:
The IEEE 754 binary16 floating point.
- to_f32(self) Float32
Converts the IEEE 754 binary128 floating point to a binary32 floating point.
The result is the same as that of
f128_to_f32().- Returns:
The IEEE 754 binary32 floating point.
- to_f64(self) Float64
Converts the IEEE 754 binary128 floating point to a binary64 floating point.
The result is the same as that of
f128_to_f64().- Returns:
The IEEE 754 binary64 floating point.
- to_float(self) double
Returns the native data as a floating point.
- Returns:
A floating point that represents the native data.
Note
Cannot return the exact number if it is unable to be expressed as an IEEE 754 binary64 floating point.
- to_i32(self, rounding_mode=None, bool exact=True) Int32
Converts the IEEE 754 binary128 floating point to a 32-bit signed integer.
The result is the same as that of
f128_to_i32().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit signed integer.
- to_i64(self, rounding_mode=None, bool exact=True) Int64
Converts the IEEE 754 binary128 floating point to a 64-bit signed integer.
The result is the same as that of
f128_to_i64().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit signed integer.
- to_ui32(self, rounding_mode=None, bool exact=True) UInt32
Converts the IEEE 754 binary128 floating point to a 32-bit unsigned integer.
The result is the same as that of
f128_to_ui32().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit unsigned integer.
- to_ui64(self, rounding_mode=None, bool exact=True) UInt64
Converts the IEEE 754 binary128 floating point to a 64-bit unsigned integer.
The result is the same as that of
f128_to_ui64().- Parameters:
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit unsigned integer.
- softfloatpy.set_tininess_mode(TininessMode mode) void
Sets the tininess detection mode.
- Parameters:
mode – The tininess detection mode to be set.
- softfloatpy.get_tininess_mode() TininessMode
Returns the current tininess detection mode.
- Returns:
The current tininess detection mode.
- softfloatpy.set_rounding_mode(RoundingMode mode) void
Sets the rounding mode.
- Parameters:
mode – The rounding mode to be set.
- softfloatpy.get_rounding_mode() RoundingMode
Returns the current rounding mode.
- Returns:
The current rounding mode.
- softfloatpy.set_exception_flags(flags) void
Sets the floating-point exception flags.
- Parameters:
flags – The floating-point exception flags to be set.
- softfloatpy.get_exception_flags()
Returns the current floating-point exception flags.
- Returns:
The current floating-point exception flags.
- softfloatpy.test_exception_flags(flags) bool
Tests the floating-point exception flags.
- Parameters:
flags – The floating-point exception flags to be tested.
- Returns:
Trueif any of the specified exception flags is nonzero,Falseotherwise.
- softfloatpy.ui32_to_f16(UInt32 x) Float16
Converts the 32-bit unsigned integer to an IEEE 754 binary16 floating point.
- Parameters:
x – The 32-bit unsigned integer to be converted.
- Returns:
The IEEE 754 binary16 floating point.
- softfloatpy.ui32_to_f32(UInt32 x) Float32
Converts the 32-bit unsigned integer to an IEEE 754 binary32 floating point.
- Parameters:
x – The 32-bit unsigned integer to be converted.
- Returns:
The IEEE 754 binary32 floating point.
- softfloatpy.ui32_to_f64(UInt32 x) Float64
Converts the 32-bit unsigned integer to an IEEE 754 binary64 floating point.
- Parameters:
x – The 32-bit unsigned integer to be converted.
- Returns:
The IEEE 754 binary64 floating point.
- softfloatpy.ui32_to_f128(UInt32 x) Float128
Converts the 32-bit unsigned integer to an IEEE 754 binary128 floating point.
- Parameters:
x – The 32-bit unsigned integer to be converted.
- Returns:
The IEEE 754 binary128 floating point.
- softfloatpy.ui64_to_f16(UInt64 x) Float16
Converts the 64-bit unsigned integer to an IEEE 754 binary16 floating point.
- Parameters:
x – The 64-bit unsigned integer to be converted.
- Returns:
The IEEE 754 binary16 floating point.
- softfloatpy.ui64_to_f32(UInt64 x) Float32
Converts the 64-bit unsigned integer to an IEEE 754 binary32 floating point.
- Parameters:
x – The 64-bit unsigned integer to be converted.
- Returns:
The IEEE 754 binary32 floating point.
- softfloatpy.ui64_to_f64(UInt64 x) Float64
Converts the 64-bit unsigned integer to an IEEE 754 binary64 floating point.
- Parameters:
x – The 64-bit unsigned integer to be converted.
- Returns:
The IEEE 754 binary64 floating point.
- softfloatpy.ui64_to_f128(UInt64 x) Float128
Converts the 64-bit unsigned integer to an IEEE 754 binary128 floating point.
- Parameters:
x – The 64-bit unsigned integer to be converted.
- Returns:
The IEEE 754 binary128 floating point.
- softfloatpy.i32_to_f16(Int32 x) Float16
Converts the 32-bit signed integer to an IEEE 754 binary16 floating point.
- Parameters:
x – The 32-bit signed integer to be converted.
- Returns:
The IEEE 754 binary16 floating point.
- softfloatpy.i32_to_f32(Int32 x) Float32
Converts the 32-bit signed integer to an IEEE 754 binary32 floating point.
- Parameters:
x – The 32-bit signed integer to be converted.
- Returns:
The IEEE 754 binary32 floating point.
- softfloatpy.i32_to_f64(Int32 x) Float64
Converts the 32-bit signed integer to an IEEE 754 binary64 floating point.
- Parameters:
x – The 32-bit signed integer to be converted.
- Returns:
The IEEE 754 binary64 floating point.
- softfloatpy.i32_to_f128(Int32 x) Float128
Converts the 32-bit signed integer to an IEEE 754 binary128 floating point.
- Parameters:
x – The 32-bit signed integer to be converted.
- Returns:
The IEEE 754 binary128 floating point.
- softfloatpy.i64_to_f16(Int64 x) Float16
Converts the 64-bit signed integer to an IEEE 754 binary16 floating point.
- Parameters:
x – The 64-bit signed integer to be converted.
- Returns:
The IEEE 754 binary16 floating point.
- softfloatpy.i64_to_f32(Int64 x) Float32
Converts the 64-bit signed integer to an IEEE 754 binary32 floating point.
- Parameters:
x – The 64-bit signed integer to be converted.
- Returns:
The IEEE 754 binary32 floating point.
- softfloatpy.i64_to_f64(Int64 x) Float64
Converts the 64-bit signed integer to an IEEE 754 binary64 floating point.
- Parameters:
x – The 64-bit signed integer to be converted.
- Returns:
The IEEE 754 binary64 floating point.
- softfloatpy.i64_to_f128(Int64 x) Float128
Converts the 64-bit signed integer to an IEEE 754 binary128 floating point.
- Parameters:
x – The 64-bit signed integer to be converted.
- Returns:
The IEEE 754 binary128 floating point.
- softfloatpy.f16_to_ui32(Float16 x, rounding_mode=None, bool exact=True) UInt32
Converts the IEEE 754 binary16 floating point to a 32-bit unsigned integer.
- Parameters:
x – The IEEE 754 binary16 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit unsigned integer.
- softfloatpy.f16_to_ui64(Float16 x, rounding_mode=None, bool exact=True) UInt64
Converts the IEEE 754 binary16 floating point to a 64-bit unsigned integer.
- Parameters:
x – The IEEE 754 binary16 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit unsigned integer.
- softfloatpy.f16_to_i32(Float16 x, rounding_mode=None, bool exact=True) Int32
Converts the IEEE 754 binary16 floating point to a 32-bit signed integer.
- Parameters:
x – The IEEE 754 binary16 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit signed integer.
- softfloatpy.f16_to_i64(Float16 x, rounding_mode=None, bool exact=True) Int64
Converts the IEEE 754 binary16 floating point to a 64-bit signed integer.
- Parameters:
x – The IEEE 754 binary16 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit signed integer.
- softfloatpy.f16_to_f32(Float16 x) Float32
Converts the IEEE 754 binary16 floating point to a binary32 floating point.
- Parameters:
x – The IEEE 754 binary16 floating point to be converted.
- Returns:
The IEEE 754 binary32 floating point.
- softfloatpy.f16_to_f64(Float16 x) Float64
Converts the IEEE 754 binary16 floating point to a binary64 floating point.
- Parameters:
x – The IEEE 754 binary16 floating point to be converted.
- Returns:
The IEEE 754 binary64 floating point.
- softfloatpy.f16_to_f128(Float16 x) Float128
Converts the IEEE 754 binary16 floating point to a binary128 floating point.
- Parameters:
x – The IEEE 754 binary16 floating point to be converted.
- Returns:
The IEEE 754 binary128 floating point.
- softfloatpy.f16_round_to_int(Float16 x, rounding_mode=None, bool exact=True) Float16
Rounds the number expressed as an IEEE 754 binary16 floating point.
- Parameters:
x – The IEEE 754 binary16 floating point to be rounded.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact rounding is unable.
- Returns:
The resulted integer expressed as an IEEE 754 binary16 floating point.
- softfloatpy.f16_neg(Float16 x) Float16
Negates the IEEE 754 binary16 floating point.
- Parameters:
x – The floating point to be negated.
- Returns:
The resulted number expressed as an IEEE 754 binary16 floating point (
-x).
- softfloatpy.f16_add(Float16 x, Float16 y) Float16
Adds the IEEE 754 binary16 floating points.
- Parameters:
x – The floating point to be added.
y – The floating point to add.
- Returns:
The resulted number expressed as an IEEE 754 binary16 floating point (
x + y).
- softfloatpy.f16_sub(Float16 x, Float16 y) Float16
Subtracts the IEEE 754 binary16 floating points.
- Parameters:
x – The floating point to be subtracted.
y – The floating point to subtract.
- Returns:
The resulted number expressed as an IEEE 754 binary16 floating point (
x - y).
- softfloatpy.f16_mul(Float16 x, Float16 y) Float16
Multiplies the IEEE 754 binary16 floating points.
- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
- Returns:
The resulted number expressed as an IEEE 754 binary16 floating point (
x * y).
- softfloatpy.f16_mul_add(Float16 x, Float16 y, Float16 z) Float16
Multiplies and Adds the IEEE 754 binary16 floating points.
- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
z – The floating point to add.
- Returns:
The resulted number expressed as an IEEE 754 binary16 floating point (
x * y + z).
- softfloatpy.f16_div(Float16 x, Float16 y) Float16
Divides the IEEE 754 binary16 floating points.
- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number expressed as an IEEE 754 binary16 floating point (
x / y).
- softfloatpy.f16_rem(Float16 x, Float16 y) Float16
Calculates a remainder by dividing the IEEE 754 binary16 floating points.
- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number expressed as an IEEE 754 binary16 floating point (
x % y).
- softfloatpy.f16_sqrt(Float16 x) Float16
Calculates a square root of the IEEE 754 binary16 floating point.
- Parameters:
x – The floating point whose square root is to be calculated.
- Returns:
The resulted number expressed as an IEEE 754 binary16 floating point (
sqrt(x)).
- softfloatpy.f16_eq(Float16 x, Float16 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary16 floating points.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- softfloatpy.f16_le(Float16 x, Float16 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary16 floating points.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- softfloatpy.f16_lt(Float16 x, Float16 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary16 floating points.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- softfloatpy.f16_eq_signaling(Float16 x, Float16 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary16 floating points.
The invalid exception flag is set for any NaN input, not just for signaling NaNs.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- softfloatpy.f16_le_quiet(Float16 x, Float16 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary16 floating points.
The invalid exception flag is not set for quiet NaNs.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- softfloatpy.f16_lt_quiet(Float16 x, Float16 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary16 floating points.
The invalid exception flag is not set for quiet NaNs.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- softfloatpy.f16_is_signaling_nan(Float16 x) bool
Tests if the IEEE 754 binary16 floating point is a signaling NaN.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is a signaling NaN,Falseotherwise.
- softfloatpy.f16_is_nan(Float16 x) bool
Tests if the IEEE 754 binary16 floating point is a NaN.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is a NaN,Falseotherwise.
- softfloatpy.f16_is_inf(Float16 x) bool
Tests if the IEEE 754 binary16 floating point is an infinity.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is an infinity,Falseotherwise.
- softfloatpy.bf16_to_f32(BFloat16 x) Float32
Converts the 16-bit brain floating point to an IEEE 754 binary32 floating point.
- Parameters:
x – The 16-bit brain floating point to be converted.
- Returns:
The IEEE 754 binary32 floating point.
- softfloatpy.f32_to_bf16(Float32 x) BFloat16
Converts the IEEE 754 binary32 floating point to a 16-bit brain floating point.
- Parameters:
x – The IEEE 754 binary32 floating point to be converted.
- Returns:
The 16-bit brain floating point.
- softfloatpy.bf16_is_signaling_nan(BFloat16 x) bool
Tests if the 16-bit brain floating point is a signaling NaN.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is a signaling NaN,Falseotherwise.
- softfloatpy.bf16_is_nan(BFloat16 x) bool
Tests if the 16-bit brain floating point is a NaN.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is a NaN,Falseotherwise.
- softfloatpy.bf16_is_inf(BFloat16 x) bool
Tests if the 16-bit brain floating point is an infinity.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is an infinity,Falseotherwise.
- softfloatpy.f32_to_ui32(Float32 x, rounding_mode=None, bool exact=True) UInt32
Converts the IEEE 754 binary32 floating point to a 32-bit unsigned integer.
- Parameters:
x – The IEEE 754 binary32 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit unsigned integer.
- softfloatpy.f32_to_ui64(Float32 x, rounding_mode=None, bool exact=True) UInt64
Converts the IEEE 754 binary32 floating point to a 64-bit unsigned integer.
- Parameters:
x – The IEEE 754 binary32 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit unsigned integer.
- softfloatpy.f32_to_i32(Float32 x, rounding_mode=None, bool exact=True) Int32
Converts the IEEE 754 binary32 floating point to a 32-bit signed integer.
- Parameters:
x – The IEEE 754 binary32 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit signed integer.
- softfloatpy.f32_to_i64(Float32 x, rounding_mode=None, bool exact=True) Int64
Converts the IEEE 754 binary32 floating point to a 64-bit signed integer.
- Parameters:
x – The IEEE 754 binary32 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit signed integer.
- softfloatpy.f32_to_f16(Float32 x) Float16
Converts the IEEE 754 binary32 floating point to a binary16 floating point.
- Parameters:
x – The IEEE 754 binary32 floating point to be converted.
- Returns:
The IEEE 754 binary16 floating point.
- softfloatpy.f32_to_f64(Float32 x) Float64
Converts the IEEE 754 binary32 floating point to a binary64 floating point.
- Parameters:
x – The IEEE 754 binary32 floating point to be converted.
- Returns:
The IEEE 754 binary64 floating point.
- softfloatpy.f32_to_f128(Float32 x) Float128
Converts the IEEE 754 binary32 floating point to a binary128 floating point.
- Parameters:
x – The IEEE 754 binary32 floating point to be converted.
- Returns:
The IEEE 754 binary128 floating point.
- softfloatpy.f32_round_to_int(Float32 x, rounding_mode=None, bool exact=True) Float32
Rounds the number expressed as an IEEE 754 binary32 floating point.
- Parameters:
x – The IEEE 754 binary32 floating point to be rounded.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact rounding is unable.
- Returns:
The resulted integer expressed as an IEEE 754 binary32 floating point.
- softfloatpy.f32_neg(Float32 x) Float32
Negates the IEEE 754 binary32 floating point.
- Parameters:
x – The floating point to be negated.
- Returns:
The resulted number expressed as an IEEE 754 binary32 floating point (
-x).
- softfloatpy.f32_add(Float32 x, Float32 y) Float32
Adds the IEEE 754 binary32 floating points.
- Parameters:
x – The floating point to be added.
y – The floating point to add.
- Returns:
The resulted number expressed as an IEEE 754 binary32 floating point (
x + y).
- softfloatpy.f32_sub(Float32 x, Float32 y) Float32
Subtracts the IEEE 754 binary32 floating points.
- Parameters:
x – The floating point to be subtracted.
y – The floating point to subtract.
- Returns:
The resulted number expressed as an IEEE 754 binary32 floating point (
x - y).
- softfloatpy.f32_mul(Float32 x, Float32 y) Float32
Multiplies the IEEE 754 binary32 floating points.
- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
- Returns:
The resulted number expressed as an IEEE 754 binary32 floating point (
x * y).
- softfloatpy.f32_mul_add(Float32 x, Float32 y, Float32 z) Float32
Multiplies and Adds the IEEE 754 binary32 floating points.
- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
z – The floating point to add.
- Returns:
The resulted number expressed as an IEEE 754 binary32 floating point (
x * y + z).
- softfloatpy.f32_div(Float32 x, Float32 y) Float32
Divides the IEEE 754 binary32 floating points.
- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number expressed as an IEEE 754 binary32 floating point (
x / y).
- softfloatpy.f32_rem(Float32 x, Float32 y) Float32
Calculates a remainder by dividing the IEEE 754 binary32 floating points.
- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number expressed as an IEEE 754 binary32 floating point (
x % y).
- softfloatpy.f32_sqrt(Float32 x) Float32
Calculates a square root of the IEEE 754 binary32 floating point.
- Parameters:
x – The floating point whose square root is to be calculated.
- Returns:
The resulted number expressed as an IEEE 754 binary32 floating point (
sqrt(x)).
- softfloatpy.f32_eq(Float32 x, Float32 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary32 floating points.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- softfloatpy.f32_le(Float32 x, Float32 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary32 floating points.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- softfloatpy.f32_lt(Float32 x, Float32 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary32 floating points.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- softfloatpy.f32_eq_signaling(Float32 x, Float32 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary32 floating points.
The invalid exception flag is set for any NaN input, not just for signaling NaNs.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- softfloatpy.f32_le_quiet(Float32 x, Float32 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary32 floating points.
The invalid exception flag is not set for quiet NaNs.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- softfloatpy.f32_lt_quiet(Float32 x, Float32 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary32 floating points.
The invalid exception flag is not set for quiet NaNs.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- softfloatpy.f32_is_signaling_nan(Float32 x) bool
Tests if the IEEE 754 binary32 floating point is a signaling NaN.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is a signaling NaN,Falseotherwise.
- softfloatpy.f32_is_nan(Float32 x) bool
Tests if the IEEE 754 binary32 floating point is a NaN.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is a NaN,Falseotherwise.
- softfloatpy.f32_is_inf(Float32 x) bool
Tests if the IEEE 754 binary32 floating point is an infinity.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is an infinity,Falseotherwise.
- softfloatpy.f64_to_ui32(Float64 x, rounding_mode=None, bool exact=True) UInt32
Converts the IEEE 754 binary64 floating point to a 32-bit unsigned integer.
- Parameters:
x – The IEEE 754 binary64 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit unsigned integer.
- softfloatpy.f64_to_ui64(Float64 x, rounding_mode=None, bool exact=True) UInt64
Converts the IEEE 754 binary64 floating point to a 64-bit unsigned integer.
- Parameters:
x – The IEEE 754 binary64 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit unsigned integer.
- softfloatpy.f64_to_i32(Float64 x, rounding_mode=None, bool exact=True) Int32
Converts the IEEE 754 binary64 floating point to a 32-bit signed integer.
- Parameters:
x – The IEEE 754 binary64 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit signed integer.
- softfloatpy.f64_to_i64(Float64 x, rounding_mode=None, bool exact=True) Int64
Converts the IEEE 754 binary64 floating point to a 64-bit signed integer.
- Parameters:
x – The IEEE 754 binary64 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit signed integer.
- softfloatpy.f64_to_f16(Float64 x) Float16
Converts the IEEE 754 binary64 floating point to a binary16 floating point.
- Parameters:
x – The IEEE 754 binary64 floating point to be converted.
- Returns:
The IEEE 754 binary16 floating point.
- softfloatpy.f64_to_f32(Float64 x) Float32
Converts the IEEE 754 binary64 floating point to a binary32 floating point.
- Parameters:
x – The IEEE 754 binary64 floating point to be converted.
- Returns:
The IEEE 754 binary32 floating point.
- softfloatpy.f64_to_f128(Float64 x) Float128
Converts the IEEE 754 binary64 floating point to a binary128 floating point.
- Parameters:
x – The IEEE 754 binary64 floating point to be converted.
- Returns:
The IEEE 754 binary128 floating point.
- softfloatpy.f64_round_to_int(Float64 x, rounding_mode=None, bool exact=True) Float64
Rounds the number expressed as an IEEE 754 binary64 floating point.
- Parameters:
x – The IEEE 754 binary64 floating point to be rounded.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact rounding is unable.
- Returns:
The resulted integer expressed as an IEEE 754 binary64 floating point.
- softfloatpy.f64_neg(Float64 x) Float64
Negates the IEEE 754 binary64 floating point.
- Parameters:
x – The floating point to be negated.
- Returns:
The resulted number expressed as an IEEE 754 binary64 floating point (
-x).
- softfloatpy.f64_add(Float64 x, Float64 y) Float64
Adds the IEEE 754 binary64 floating points.
- Parameters:
x – The floating point to be added.
y – The floating point to add.
- Returns:
The resulted number expressed as an IEEE 754 binary64 floating point (
x + y).
- softfloatpy.f64_sub(Float64 x, Float64 y) Float64
Subtracts the IEEE 754 binary64 floating points.
- Parameters:
x – The floating point to be subtracted.
y – The floating point to subtract.
- Returns:
The resulted number expressed as an IEEE 754 binary64 floating point (
x - y).
- softfloatpy.f64_mul(Float64 x, Float64 y) Float64
Multiplies the IEEE 754 binary64 floating points.
- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
- Returns:
The resulted number expressed as an IEEE 754 binary64 floating point (
x * y).
- softfloatpy.f64_mul_add(Float64 x, Float64 y, Float64 z) Float64
Multiplies and Adds the IEEE 754 binary64 floating points.
- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
z – The floating point to add.
- Returns:
The resulted number expressed as an IEEE 754 binary64 floating point (
x * y + z).
- softfloatpy.f64_div(Float64 x, Float64 y) Float64
Divides the IEEE 754 binary64 floating points.
- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number expressed as an IEEE 754 binary64 floating point (
x / y).
- softfloatpy.f64_rem(Float64 x, Float64 y) Float64
Calculates a remainder by dividing the IEEE 754 binary64 floating points.
- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number expressed as an IEEE 754 binary64 floating point (
x % y).
- softfloatpy.f64_sqrt(Float64 x) Float64
Calculates a square root of the IEEE 754 binary64 floating point.
- Parameters:
x – The floating point whose square root is to be calculated.
- Returns:
The resulted number expressed as an IEEE 754 binary64 floating point (
sqrt(x)).
- softfloatpy.f64_eq(Float64 x, Float64 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary64 floating points.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- softfloatpy.f64_le(Float64 x, Float64 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary64 floating points.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- softfloatpy.f64_lt(Float64 x, Float64 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary64 floating points.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- softfloatpy.f64_eq_signaling(Float64 x, Float64 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary64 floating points.
The invalid exception flag is set for any NaN input, not just for signaling NaNs.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- softfloatpy.f64_le_quiet(Float64 x, Float64 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary64 floating points.
The invalid exception flag is not set for quiet NaNs.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- softfloatpy.f64_lt_quiet(Float64 x, Float64 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary64 floating points.
The invalid exception flag is not set for quiet NaNs.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- softfloatpy.f64_is_signaling_nan(Float64 x) bool
Tests if the IEEE 754 binary64 floating point is a signaling NaN.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is a signaling NaN,Falseotherwise.
- softfloatpy.f64_is_nan(Float64 x) bool
Tests if the IEEE 754 binary64 floating point is a NaN.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is a NaN,Falseotherwise.
- softfloatpy.f64_is_inf(Float64 x) bool
Tests if the IEEE 754 binary64 floating point is an infinity.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is an infinity,Falseotherwise.
- softfloatpy.f128_to_ui32(Float128 x, rounding_mode=None, bool exact=True) UInt32
Converts the IEEE 754 binary128 floating point to a 32-bit unsigned integer.
- Parameters:
x – The IEEE 754 binary128 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit unsigned integer.
- softfloatpy.f128_to_ui64(Float128 x, rounding_mode=None, bool exact=True) UInt64
Converts the IEEE 754 binary128 floating point to a 64-bit unsigned integer.
- Parameters:
x – The IEEE 754 binary128 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit unsigned integer.
- softfloatpy.f128_to_i32(Float128 x, rounding_mode=None, bool exact=True) Int32
Converts the IEEE 754 binary128 floating point to a 32-bit signed integer.
- Parameters:
x – The IEEE 754 binary128 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 32-bit signed integer.
- softfloatpy.f128_to_i64(Float128 x, rounding_mode=None, bool exact=True) Int64
Converts the IEEE 754 binary128 floating point to a 64-bit signed integer.
- Parameters:
x – The IEEE 754 binary128 floating point to be converted.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact conversion is unable.
- Returns:
The 64-bit signed integer.
- softfloatpy.f128_to_f16(Float128 x) Float16
Converts the IEEE 754 binary128 floating point to a binary16 floating point.
- Parameters:
x – The IEEE 754 binary128 floating point to be converted.
- Returns:
The IEEE 754 binary16 floating point.
- softfloatpy.f128_to_f32(Float128 x) Float32
Converts the IEEE 754 binary128 floating point to a binary32 floating point.
- Parameters:
x – The IEEE 754 binary128 floating point to be converted.
- Returns:
The IEEE 754 binary32 floating point.
- softfloatpy.f128_to_f64(Float128 x) Float64
Converts the IEEE 754 binary128 floating point to a binary64 floating point.
- Parameters:
x – The IEEE 754 binary128 floating point to be converted.
- Returns:
The IEEE 754 binary64 floating point.
- softfloatpy.f128_round_to_int(Float128 x, rounding_mode=None, bool exact=True) Float128
Rounds the number expressed as an IEEE 754 binary128 floating point.
- Parameters:
x – The IEEE 754 binary128 floating point to be rounded.
rounding_mode – The rounding mode. If
Noneis specified, the current rounding mode is used.exact – If
Trueis specified, the floating-point exception flags are to be set when exact rounding is unable.
- Returns:
The resulted integer expressed as an IEEE 754 binary128 floating point.
- softfloatpy.f128_neg(Float128 x) Float128
Negates the IEEE 754 binary128 floating point.
- Parameters:
x – The floating point to be negated.
- Returns:
The resulted number expressed as an IEEE 754 binary128 floating point (
-x).
- softfloatpy.f128_add(Float128 x, Float128 y) Float128
Adds the IEEE 754 binary128 floating points.
- Parameters:
x – The floating point to be added.
y – The floating point to add.
- Returns:
The resulted number expressed as an IEEE 754 binary128 floating point (
x + y).
- softfloatpy.f128_sub(Float128 x, Float128 y) Float128
Subtracts the IEEE 754 binary128 floating points.
- Parameters:
x – The floating point to be subtracted.
y – The floating point to subtract.
- Returns:
The resulted number expressed as an IEEE 754 binary128 floating point (
x - y).
- softfloatpy.f128_mul(Float128 x, Float128 y) Float128
Multiplies the IEEE 754 binary128 floating points.
- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
- Returns:
The resulted number expressed as an IEEE 754 binary128 floating point (
x * y).
- softfloatpy.f128_mul_add(Float128 x, Float128 y, Float128 z) Float128
Multiplies and Adds the IEEE 754 binary128 floating points.
- Parameters:
x – The floating point to be multiplied.
y – The floating point to multiply.
z – The floating point to add.
- Returns:
The resulted number expressed as an IEEE 754 binary128 floating point (
x * y + z).
- softfloatpy.f128_div(Float128 x, Float128 y) Float128
Divides the IEEE 754 binary128 floating points.
- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number expressed as an IEEE 754 binary128 floating point (
x / y).
- softfloatpy.f128_rem(Float128 x, Float128 y) Float128
Calculates a remainder by dividing the IEEE 754 binary128 floating points.
- Parameters:
x – The floating point to be divided.
y – The floating point to divide.
- Returns:
The resulted number expressed as an IEEE 754 binary128 floating point (
x % y).
- softfloatpy.f128_sqrt(Float128 x) Float128
Calculates a square root of the IEEE 754 binary128 floating point.
- Parameters:
x – The floating point whose square root is to be calculated.
- Returns:
The resulted number expressed as an IEEE 754 binary128 floating point (
sqrt(x)).
- softfloatpy.f128_eq(Float128 x, Float128 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary128 floating points.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- softfloatpy.f128_le(Float128 x, Float128 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary128 floating points.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- softfloatpy.f128_lt(Float128 x, Float128 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary128 floating points.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- softfloatpy.f128_eq_signaling(Float128 x, Float128 y) bool
Tests if the first one is equal to the second one expressed as IEEE 754 binary128 floating points.
The invalid exception flag is set for any NaN input, not just for signaling NaNs.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is equal to the second one,Falseotherwise (x == y).
- softfloatpy.f128_le_quiet(Float128 x, Float128 y) bool
Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary128 floating points.
The invalid exception flag is not set for quiet NaNs.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than or equal to the second one,Falseotherwise (x <= y).
- softfloatpy.f128_lt_quiet(Float128 x, Float128 y) bool
Tests if the first one is less than the second one expressed as IEEE 754 binary128 floating points.
The invalid exception flag is not set for quiet NaNs.
- Parameters:
x – The first floating point to be compared.
y – The second floating point to be compared.
- Returns:
Trueif the first one is less than the second one,Falseotherwise (x < y).
- softfloatpy.f128_is_signaling_nan(Float128 x) bool
Tests if the IEEE 754 binary128 floating point is a signaling NaN.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is a signaling NaN,Falseotherwise.
- softfloatpy.f128_is_nan(Float128 x) bool
Tests if the IEEE 754 binary128 floating point is a NaN.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is a NaN,Falseotherwise.
- softfloatpy.f128_is_inf(Float128 x) bool
Tests if the IEEE 754 binary128 floating point is an infinity.
- Parameters:
x – The floating point to be tested.
- Returns:
Trueif the floating point is an infinity,Falseotherwise.