- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 12 for SetPrec (0.12 sec)
-
src/math/big/floatexample_test.go
// Operate on numbers of different precision. var x, y, z big.Float x.SetInt64(1000) // x is automatically set to 64bit precision y.SetFloat64(2.718281828) // y is automatically set to 53bit precision z.SetPrec(32) z.Add(&x, &y) fmt.Printf("x = %.10g (%s, prec = %d, acc = %s)\n", &x, x.Text('p', 0), x.Prec(), x.Acc()) fmt.Printf("y = %.10g (%s, prec = %d, acc = %s)\n", &y, y.Text('p', 0), y.Prec(), y.Acc())
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu Jun 06 15:46:54 UTC 2024 - 4.1K bytes - Viewed (0) -
src/math/big/float_test.go
for _, prec := range precList { two := new(Float).SetPrec(prec).SetInt64(2) one := new(Float).SetPrec(prec).SetInt64(1) three := new(Float).SetPrec(prec).SetInt64(3) msix := new(Float).SetPrec(prec).SetInt64(-6) psix := new(Float).SetPrec(prec).SetInt64(+6) p := new(Float).SetPrec(prec) z1 := new(Float).SetPrec(prec) z2 := new(Float).SetPrec(prec) // z1 = 2 + 1.0/3*-6 p.Quo(one, three)
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu Apr 11 20:22:45 UTC 2024 - 51.9K bytes - Viewed (0) -
src/math/big/floatmarsh_test.go
x := sign + test var tx Float _, _, err := tx.SetPrec(prec).SetMode(mode).Parse(x, 0) if err != nil { t.Errorf("parsing of %s (%dbits, %v) failed (invalid test case): %v", x, prec, mode, err) continue } // If tx was set to prec == 0, tx.Parse(x, 0) assumes precision 64. Correct it. if prec == 0 { tx.SetPrec(0) } if err := enc.Encode(&tx); err != nil {
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Mon Jan 23 18:18:05 UTC 2023 - 4.5K bytes - Viewed (0) -
src/math/big/floatconv.go
err = fmt.Errorf("exponent overflow") return } if exp5 == 0 { // no decimal exponent contribution z.round(0) return } // exp5 != 0 // apply 5**exp5 p := new(Float).SetPrec(z.Prec() + 64) // use more bits for p -- TODO(gri) what is the right number? if exp5 < 0 { z.Quo(z, p.pow5(uint64(-exp5))) } else { z.Mul(z, p.pow5(uint64(exp5))) } return }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu Oct 19 11:59:09 UTC 2023 - 8.3K bytes - Viewed (0) -
src/math/big/floatmarsh.go
return errors.New("Float.GobDecode: buffer too small for finite form float") } z.exp = int32(byteorder.BeUint32(buf[6:])) z.mant = z.mant.setBytes(buf[10:]) } if oldPrec != 0 { z.mode = oldMode z.SetPrec(uint(oldPrec)) } if msg := z.validate0(); msg != "" { return errors.New("Float.GobDecode: " + msg) } return nil } // MarshalText implements the [encoding.TextMarshaler] interface.
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Mon May 13 21:31:58 UTC 2024 - 3.6K bytes - Viewed (0) -
src/cmd/compile/internal/ir/const.go
const ( // Maximum size in bits for big.Ints before signaling // overflow and also mantissa precision for big.Floats. ConstPrec = 512 ) func BigFloat(v constant.Value) *big.Float { f := new(big.Float) f.SetPrec(ConstPrec) switch u := constant.Val(v).(type) { case int64: f.SetInt64(u) case *big.Int: f.SetInt(u) case *big.Float: f.Set(u) case *big.Rat: f.SetRat(u) default:
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Sep 12 18:53:26 UTC 2023 - 4K bytes - Viewed (0) -
src/math/big/bits_test.go
if mode == ToNearestAway { panic("not yet implemented") } if mode == ToNearestEven && rbit == 1 && (sbit == 1 || sbit == 0 && bit0 != 0) || mode == AwayFromZero { // round away from zero f.SetMode(ToZero).SetPrec(prec) f.Add(f, Bits{int(r) + 1}.Float()) } return f } // Float returns the *Float z of the smallest possible precision such that // z = sum(2**bits[i]), with i = range bits. If multiple bits[i] are equal,
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu May 23 01:00:11 UTC 2024 - 5.1K bytes - Viewed (0) -
src/math/big/float.go
//go:generate stringer -type=Accuracy // SetPrec sets z's precision to prec and returns the (possibly) rounded // value of z. Rounding occurs according to z's rounding mode if the mantissa // cannot be represented in prec bits without loss of precision. // SetPrec(0) maps all finite values to ±0; infinite values remain unchanged. // If prec > [MaxPrec], it is set to [MaxPrec]. func (z *Float) SetPrec(prec uint) *Float {
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu Jun 06 15:46:54 UTC 2024 - 44.5K bytes - Viewed (0) -
src/math/big/ftoa.go
} // round mantissa to n bits var n uint if prec < 0 { n = 1 + (x.MinPrec()-1+3)/4*4 // round MinPrec up to 1 mod 4 } else { n = 1 + 4*uint(prec) } // n%4 == 1 x = new(Float).SetPrec(n).SetMode(x.mode).Set(x) // adjust mantissa to use exactly n bits m := x.mant switch w := uint(len(x.mant)) * _W; { case w < n: m = nat(nil).shl(m, n-w) case w > n: m = nat(nil).shr(m, w-n)
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu Oct 19 11:59:09 UTC 2023 - 13.5K bytes - Viewed (0) -
src/internal/pkgbits/decoder.go
func (r *Decoder) bigInt() *big.Int { v := new(big.Int).SetBytes([]byte(r.String())) if r.Bool() { v.Neg(v) } return v } func (r *Decoder) bigFloat() *big.Float { v := new(big.Float).SetPrec(512) assert(v.UnmarshalText([]byte(r.String())) == nil) return v } // @@@ Helpers // TODO(mdempsky): These should probably be removed. I think they're a
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Sep 27 20:58:46 UTC 2022 - 13.2K bytes - Viewed (0)