Documentation ¶
Index ¶
- Constants
- Variables
- func Raise(x int)
- type X80
- func (a X80) Add(b X80) X80
- func (a X80) Append(dst []byte, fmt byte, prec int) []byte
- func (a X80) Bytes(order binary.ByteOrder) []byte
- func (a X80) Div(b X80) X80
- func (a X80) Eq(b X80) bool
- func (a X80) EqSignaling(b X80) bool
- func (a X80) Format(fmt byte, prec int) string
- func (a X80) Ge(b X80) bool
- func (a X80) GeQuiet(b X80) bool
- func (a X80) Gt(b X80) bool
- func (a X80) GtQuiet(b X80) bool
- func (a X80) Internal() string
- func (a X80) IsNaN() bool
- func (a X80) IsSignalingNaN() bool
- func (a X80) Le(b X80) bool
- func (a X80) LeQuiet(b X80) bool
- func (a X80) Lt(b X80) bool
- func (a X80) LtQuiet(b X80) bool
- func (a X80) Mul(b X80) X80
- func (a X80) Rem(b X80) X80
- func (a X80) RoundToInt() X80
- func (a X80) Sqrt() X80
- func (a X80) String() string
- func (a X80) Sub(b X80) X80
- func (a X80) ToFloat32() float32
- func (a X80) ToFloat64() float64
- func (a X80) ToInt32() int32
- func (a X80) ToInt32RoundZero() int32
- func (a X80) ToInt64() int64
- func (a X80) ToInt64RoundZero() int64
Examples ¶
Constants ¶
const ( TininessAfterRounding = 0 TininessBeforeRounding = 1 )
Software IEC/IEEE floating-point underflow tininess-detection mode.
const ( RoundNearestEven = 0 RoundToZero = 1 RoundDown = 2 RoundUp = 3 )
Software IEC/IEEE floating-point rounding mode.
const ( ExceptionInvalid = 0x01 ExceptionDenormal = 0x02 ExceptionDivbyzero = 0x04 ExceptionOverflow = 0x08 ExceptionUnderflow = 0x10 ExceptionInexact = 0x20 )
Software IEC/IEEE floating-point exception flags.
Variables ¶
var ( X80Zero = newFromHexString("00000000000000000000") // 0 X80One = newFromHexString("3FFF8000000000000000") // 1 X80MinusOne = newFromHexString("BFFF8000000000000000") // -1 X80E = newFromHexString("4000ADF85458A2BB4800") // e X80Pi = newFromHexString("4000C90FDAA22168C000") // pi X80Sqrt2 = newFromHexString("BFFFB504F333F9DE6800") // sqrt(2) X80Log2E = newFromHexString("3FFFB8AA3B295C17F000") // Log2(e) X80Ln2 = newFromHexString("3FFEB17217F7D1CF7800") // Ln(2) X80InfPos = newFromHexString("7FFF8000000000000000") // inf+ X80InfNeg = newFromHexString("FFFF8000000000000000") // inf- X80NaN = newFromHexString("7FFFC000000000000000") // NaN )
"constants" fpr X80 format
var DetectTininess = TininessAfterRounding
DetectTininess tininess-detection mode.
var Exception int = 0
Exception Software IEC/IEEE floating-point exception flags.
var RoundingMode = RoundNearestEven
RoundingMode Software IEC/IEEE floating-point rounding mode.
var RoundingPrecision = 80
RoundingPrecision Software IEC/IEEE extended double-precision rounding precision. Valid values are 32, 64, and 80.
Functions ¶
Types ¶
type X80 ¶
type X80 struct {
// contains filtered or unexported fields
}
X80 represents the 80-bit extended double precision floating-point type
Example ¶
package main import ( "fmt" "github.com/jenska/float" ) func main() { pi := float.X80Pi pi2 := pi.Add(pi) sqrtpi2 := pi2.Sqrt() epsilon := sqrtpi2.Mul(sqrtpi2).Sub(pi2) fmt.Println(epsilon) }
Output: -0.000000000000000000433680868994
func Float32ToFloatX80 ¶
Float32ToFloatX80 returns the result of converting the single-precision floating-point value `a' to the extended double-precision floating-point format. The conversion is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func Float64ToFloatX80 ¶
Float64ToFloatX80 returns the result of converting the double-precision floating-point value `a' to the extended double-precision floating-point format. The conversion is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func Int32ToFloatX80 ¶
Int32ToFloatX80 returns the result of converting the 32-bit two's complement integer `a' to the extended double-precision floating-point format. The conversion is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func Int64ToFloatX80 ¶
Int64ToFloatX80 returns the result of converting the 64-bit two's complement integer `a' to the extended double-precision floating-point format. The conversion is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func NewFromBytes ¶
NewFromBytes returns a new extended double precision float from a byte array in byte order LittleEndian or BigEndian
func NewFromFloat64 ¶
NewFromFloat64 returns the result of converting the double-precision floating-point value `a' to the extended double-precision floating-point format. The conversion is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) Add ¶
Add returns the result of adding the extended double-precision floating-point values `a' and `b'. The operation is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) Append ¶
Append appends the string form of the floating-point number f, as generated by FormatFloat, to dst and returns the extended buffer.
func (X80) Bytes ¶
Bytes returns a byte array in byte order LittleEndian or BigEndian of an extended double precision float
func (X80) Div ¶
Div returns the result of dividing the extended double-precision floating-point value `a' by the corresponding value `b'. The operation is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) Eq ¶
Eq returns true if the extended double-precision floating-point value `a' is equal to the corresponding value `b', and false otherwise. The comparison is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) EqSignaling ¶
EqSignaling returns true if the extended double-precision floating-point value `a' is equal to the corresponding value `b', and false otherwise. The invalid exception is raised if either operand is a NaN. Otherwise, the comparison is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) Format ¶
Format converts the extended floating-point number f to a string, according to the format fmt. It rounds the result assuming that the original was obtained from a floating-point value of 80 bits.
The format fmt is one of 'b' (-ddddp±ddd, a binary exponent), 'e' (-d.dddde±dd, a decimal exponent), 'E' (-d.ddddE±dd, a decimal exponent), 'f' (-ddd.dddd, no exponent),
The precision prec controls the number of digits (excluding the exponent) printed by the 'e', 'E', 'f' formats. For 'e', 'E', 'f' it is the number of digits after the decimal point.
func (X80) Ge ¶
Ge returns true if the extended double-precision floating-point value `a' is greater than or equal to the corresponding value `b', and false otherwise.
func (X80) GeQuiet ¶
GeQuiet returns true if the extended double-precision floating-point value `a' is greater than or equal to the corresponding value `b', and false otherwise. Quiet NaNs do not cause an exception. Otherwise, the comparison is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) Gt ¶
Gt returns true if the extended double-precision floating-point value `a' is greater than the corresponding value `b', and false otherwise.
func (X80) GtQuiet ¶
GtQuiet returns true if the extended double-precision floating-point value `a' is greater than the corresponding value `b', and false otherwise. Quiet NaNs do not cause an exception. Otherwise, the comparison is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) Internal ¶
Internal returns the internal represantion of the 80bit float value in hex format.
func (X80) IsSignalingNaN ¶
IsSignalingNaN returns true of the value is a signaling NaN, otherwise false
func (X80) Le ¶
Le returns true if the extended double-precision floating-point value `a' is less than or equal to the corresponding value `b', and false otherwise.
func (X80) LeQuiet ¶
LeQuiet returns true if the extended double-precision floating-point value `a' is less than or equal to the corresponding value `b', and false otherwise. Quiet NaNs do not cause an exception. Otherwise, the comparison is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) Lt ¶
Lt returns true if the extended double-precision floating-point value `a' is less than the corresponding value `b', and false otherwise. The comparison is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) LtQuiet ¶
LtQuiet returns true if the extended double-precision floating-point value `a' is less than the corresponding value `b', and false otherwise. Quiet NaNs do not cause an exception. Otherwise, the comparison is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) Mul ¶
Mul returns the result of multiplying the extended double-precision floating- point values `a' and `b'. The operation is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) Rem ¶
Rem returns the remainder of the extended double-precision floating-point value `a' with respect to the corresponding value `b'. The operation is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) RoundToInt ¶
RoundToInt rounds the extended double-precision floating-point value `a' to an integer, and returns the result as an extended quadruple-precision floating-point value. The operation is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) Sqrt ¶
Sqrt returns the square root of the extended double-precision floating-point value `a'. The operation is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) Sub ¶
Sub returns the result of subtracting the extended double-precision floating- point values `a' and `b'. The operation is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) ToFloat32 ¶
ToFloat32 returns the result of converting the extended double-precision floating- point value `a' to the double-precision floating-point format. The conversion is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) ToFloat64 ¶
ToFloat64 returns the result of converting the extended double-precision floating- point value `a' to the double-precision floating-point format. The conversion is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
func (X80) ToInt32 ¶
ToInt32 returns the result of converting the extended double-precision floating- point value `a' to the 32-bit two's complement integer format. The conversion is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic---which means in particular that the conversion is rounded according to the current rounding mode. If `a' is a NaN, the largest positive integer is returned. Otherwise, if the conversion overflows, the largest integer with the same sign as `a' is returned.
func (X80) ToInt32RoundZero ¶
ToInt32RoundZero returns the result of converting the extended double-precision floating- point value `a' to the 32-bit two's complement integer format. The conversion is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic, except that the conversion is always rounded toward zero. If `a' is a NaN, the largest positive integer is returned. Otherwise, if the conversion overflows, the largest integer with the same sign as `a' is returned.
func (X80) ToInt64 ¶
ToInt64 returns the result of converting the extended double-precision floating- point value `a' to the 64-bit two's complement integer format. The conversion is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic---which means in particular that the conversion is rounded according to the current rounding mode. If `a' is a NaN, the largest positive integer is returned. Otherwise, if the conversion overflows, the largest integer with the same sign as `a' is returned.
func (X80) ToInt64RoundZero ¶
ToInt64RoundZero returns the result of converting the extended double-precision floating-point value `a' to the 64-bit two's complement integer format. The conversion is performed according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic, except that the conversion is always rounded toward zero. If `a' is a NaN, the largest positive integer is returned. Otherwise, if the conversion overflows, the largest integer with the same sign as `a' is returned.