suite

package
v0.0.0-...-00de7ca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package suite provides a simple API for parsing and using IBM Labs' "Floating-Point Test-Suite for IEEE"

This package is deprecated and will be removed in the next major version.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Case

type Case struct {
	Prefix string
	Prec   int
	Op     Op
	Mode   big.RoundingMode
	Trap   Condition
	Inputs []Data
	Output Data
	Excep  Condition
}

Case represents a specific test case.

Here's a nice ascii diagram:

 prec   trap             excep
 |      |                |
 |\     |                |
 vv     v                v
d64+ =0 i 100 200 -> 300 i
^  ^ ^^   ^^^ ^^^  ^ ^^^
|  | \|   \|/ \|/  | \|/
|  |  |    |   |   |  |
|  |  mode  \ /    |  output
|  op        |     output delim
prefix       inputs

func ParseCase

func ParseCase(data []byte) (c Case, err error)

func ParseCases

func ParseCases(r io.Reader) (cases []Case, err error)

ParseCases returns a slice of test cases in .fptest form read from r.

func (Case) ShortString

func (c Case) ShortString(length int) string

ShortString returns the same as String, except long data values are capped at length digits.

func (Case) String

func (c Case) String() string

type Condition

type Condition uint32

Condition is a bitmask value raised after or during specific operations.

const (
	Clamped Condition = 1 << iota
	ConversionSyntax
	DivisionByZero
	DivisionImpossible
	DivisionUndefined
	Inexact
	InsufficientStorage
	InvalidContext
	InvalidOperation
	Overflow
	Rounded
	Subnormal
	Underflow
)

func ConditionFromString

func ConditionFromString(s string) (r Condition)

func (Condition) String

func (c Condition) String() string

type Data

type Data string

Data is input or output from a test case.

const NoData Data = "#"

NoData is output when the operation throws some sort of Condition and does not "return" any data.

func (Data) IsInf

func (i Data) IsInf() (int, bool)

IsInf returns a boolean indicating whether the data is an Infinity and an int indicating the signedness of the Infinity.

func (Data) IsNaN

func (i Data) IsNaN() (nan, signal bool)

IsNaN returns two booleans indicating whether the data is a NaN value and whether it's signaling or not.

type Op

type Op uint8

Op is a specific operation the test case must perform.

const (
	Add         Op = iota // add
	Sub                   // subtract
	Mul                   // multiply
	Div                   // divide
	FMA                   // fused multiply-add
	Sqrt                  // square root
	Rem                   // remainder
	RFI                   // round float to int
	CFF                   // convert between floating point formats
	CFI                   // convert float to integer
	CIF                   // convert integer to float
	CFD                   // convert to string
	CDF                   // convert string to float
	QuietCmp              // quiet comparison
	SigCmp                // signaling comparison
	Copy                  // copy
	Neg                   // negate
	Abs                   // absolute value
	CopySign              // copy sign
	Scalb                 // scalb
	Logb                  // logb
	NextAfter             // next after
	Class                 // class
	IsSigned              // is signed
	IsNormal              // is norm
	IsInf                 // is inf
	IsZero                // is zero
	IsSubNormal           // is subnormal
	IsNaN                 // is nan
	IsSignaling           // is signaling
	IsFinite              // is finite
	MinNum                // minnum
	MaxNum                // maxnum
	MinNumMag             // minnummag
	MaxNumMag             // maxnummag
	SameQuantum           // same quantum
	Quantize              // quantize
	NextUp                // next up
	NextDown              // next down
	Equiv                 // equivalent

	// Custom
	SetRat
	Sign
	Signbit
	Exp
	Log
	Log10
	Pow
	IntDiv
	Normalize
	RoundToInt
	Shift
)

func (Op) String

func (i Op) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL