floatconv

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Float32info = floatInfo{23, 8, -127}
View Source
var Float64info = floatInfo{52, 11, -1023}

Functions

func Atof32exact

func Atof32exact(mantissa uint64, exp int, neg bool) (f float32, ok bool)

If possible to compute mantissa*10^exp to 32-bit float f exactly, entirely in floating-point math, do so, avoiding the machinery above.

func Atof64exact

func Atof64exact(mantissa uint64, exp int, neg bool) (f float64, ok bool)

If possible to convert decimal representation to 64-bit float f exactly, entirely in floating-point math, do so, avoiding the expense of decimalToFloatBits. Three common cases:

value is exact integer
value is exact integer * exact power of ten
value is exact integer / exact power of ten

These all produce potentially inexact but correctly rounded answers.

func EiselLemire32

func EiselLemire32(man uint64, exp10 int, neg bool) (f float32, ok bool)

func EiselLemire64

func EiselLemire64(man uint64, exp10 int, neg bool) (f float64, ok bool)

Types

type Decimal

type Decimal struct {
	// contains filtered or unexported fields
}

func (*Decimal) FloatBits

func (d *Decimal) FloatBits(flt *floatInfo) (b uint64, overflow bool)

func (*Decimal) RoundedInteger

func (a *Decimal) RoundedInteger() uint64

Extract integer part, rounded appropriately. No guarantees about overflow.

func (*Decimal) Set

func (d *Decimal) Set(dat []byte, exp int, neg bool, trc bool, dp int)

func (*Decimal) Shift

func (a *Decimal) Shift(k int)

Binary shift left (k > 0) or right (k < 0).

Jump to

Keyboard shortcuts

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