Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 10 for SetPrec (0.17 sec)

  1. src/math/big/sqrt_test.go

    		{"4p-2048", "2p-1024"},
    		{"9p-4096", "3p-2048"},
    	} {
    		for _, prec := range []uint{24, 53, 64, 65, 100, 128, 129, 200, 256, 400, 600, 800, 1000} {
    			x := new(Float).SetPrec(prec)
    			x.Parse(test.x, 10)
    
    			got := new(Float).SetPrec(prec).Sqrt(x)
    			want := new(Float).SetPrec(prec)
    			want.Parse(test.want, 10)
    			if got.Cmp(want) != 0 {
    				t.Errorf("prec = %d, Sqrt(%v) =\ngot  %g;\nwant %g",
    					prec, test.x, got, want)
    			}
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed May 22 12:54:00 UTC 2019
    - 4.8K bytes
    - Viewed (0)
  2. 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)
  3. 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)
  4. src/math/big/example_test.go

    	steps := int(math.Log2(prec))
    
    	// Initialize values we need for the computation.
    	two := new(big.Float).SetPrec(prec).SetInt64(2)
    	half := new(big.Float).SetPrec(prec).SetFloat64(0.5)
    
    	// Use 1 as the initial estimate.
    	x := new(big.Float).SetPrec(prec).SetInt64(1)
    
    	// We use t as a temporary variable. There's no need to set its precision
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Aug 26 16:15:32 UTC 2020
    - 4K bytes
    - Viewed (0)
  5. src/math/big/decimal_test.go

    			var d decimal
    			d.init(natOne, shift)
    			sink = d.String()
    		}
    	}
    }
    
    func BenchmarkFloatString(b *testing.B) {
    	x := new(Float)
    	for _, prec := range []uint{1e2, 1e3, 1e4, 1e5} {
    		x.SetPrec(prec).SetRat(NewRat(1, 3))
    		b.Run(fmt.Sprintf("%v", prec), func(b *testing.B) {
    			b.ReportAllocs()
    			for i := 0; i < b.N; i++ {
    				sink = x.String()
    			}
    		})
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Oct 18 05:54:35 UTC 2016
    - 3.3K bytes
    - Viewed (0)
  6. 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)
  7. test/abi/idata.go

    		return fmt.Sprintf("%.6g", x)
    	}
    
    	return "OOPS"
    }
    
    func (x complexVal) String() string { return fmt.Sprintf("(%s + %si)", x.re, x.im) }
    
    func newFloat() *big.Float { return new(big.Float).SetPrec(prec) }
    
    //go:noinline
    //go:registerparams
    func itor(x intVal) ratVal       { return ratVal{nil} }
    
    //go:noinline
    //go:registerparams
    func itof(x intVal) floatVal     { return floatVal{nil} }
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Apr 05 20:11:08 UTC 2021
    - 2.1K bytes
    - Viewed (0)
  8. 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)
  9. 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)
  10. 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)
Back to top