MCPcopy
hub / github.com/shopspring/decimal / newConstApproximation

Function newConstApproximation

const.go:20–37  ·  view source on GitHub ↗
(value string)

Source from the content-addressed store, hash-verified

18}
19
20func newConstApproximation(value string) constApproximation {
21 parts := strings.Split(value, ".")
22 coeff, fractional := parts[0], parts[1]
23
24 coeffLen := len(coeff)
25 maxPrecision := len(fractional)
26
27 var approximations []Decimal
28 for p := 1; p < maxPrecision; p *= 2 {
29 r := RequireFromString(value[:coeffLen+p])
30 approximations = append(approximations, r)
31 }
32
33 return constApproximation{
34 RequireFromString(value),
35 approximations,
36 }
37}
38
39// Returns the smallest approximation available that's at least as precise
40// as the passed precision (places after decimal point), i.e. Floor[ log2(precision) ] + 1

Callers 2

const.goFile · 0.85
TestConstApproximationFunction · 0.85

Calls 1

RequireFromStringFunction · 0.85

Tested by 1

TestConstApproximationFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…