(value string)
| 18 | } |
| 19 | |
| 20 | func 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 |
searching dependent graphs…