Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 18 for SetPrec (0.12 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/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)
  4. 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)
  5. 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)
  6. 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)
  7. 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)
  8. 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)
  9. src/math/big/floatconv_test.go

    		// erroneous formats
    		{"%s", 1.0, "%!s(*big.Float=1)"},
    	} {
    		value := new(Float)
    		switch v := test.value.(type) {
    		case float32:
    			value.SetPrec(24).SetFloat64(float64(v))
    		case float64:
    			value.SetPrec(53).SetFloat64(v)
    		case string:
    			value.SetPrec(512).Parse(v, 0)
    		default:
    			t.Fatalf("unsupported test value: %v (%T)", v, v)
    		}
    
    		if got := fmt.Sprintf(test.format, value); got != test.want {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Dec 13 18:45:54 UTC 2021
    - 24.3K bytes
    - Viewed (0)
  10. 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)
Back to top