X7ROOT File Manager
Current Path:
/opt/golang/1.19.4/src/math/big
opt
/
golang
/
1.19.4
/
src
/
math
/
big
/
📁
..
📄
accuracy_string.go
(414 B)
📄
alias_test.go
(8.81 KB)
📄
arith.go
(8.28 KB)
📄
arith_386.s
(4.07 KB)
📄
arith_amd64.go
(306 B)
📄
arith_amd64.s
(9.09 KB)
📄
arith_arm.s
(4.03 KB)
📄
arith_arm64.s
(11.88 KB)
📄
arith_decl.go
(594 B)
📄
arith_decl_pure.go
(1.04 KB)
📄
arith_decl_s390x.go
(531 B)
📄
arith_loong64.s
(745 B)
📄
arith_mips64x.s
(817 B)
📄
arith_mipsx.s
(809 B)
📄
arith_ppc64x.s
(16.36 KB)
📄
arith_riscv64.s
(786 B)
📄
arith_s390x.s
(20.32 KB)
📄
arith_s390x_test.go
(812 B)
📄
arith_test.go
(19.88 KB)
📄
arith_wasm.s
(641 B)
📄
bits_test.go
(5.07 KB)
📄
calibrate_test.go
(4.63 KB)
📄
decimal.go
(6.63 KB)
📄
decimal_test.go
(3.33 KB)
📄
doc.go
(3.79 KB)
📄
example_rat_test.go
(1.68 KB)
📄
example_test.go
(4.05 KB)
📄
float.go
(44.28 KB)
📄
float_test.go
(51.94 KB)
📄
floatconv.go
(8.34 KB)
📄
floatconv_test.go
(24.27 KB)
📄
floatexample_test.go
(3.63 KB)
📄
floatmarsh.go
(3.53 KB)
📄
floatmarsh_test.go
(3.92 KB)
📄
ftoa.go
(13.55 KB)
📄
gcd_test.go
(2.16 KB)
📄
hilbert_test.go
(2.88 KB)
📄
int.go
(30.26 KB)
📄
int_test.go
(53.14 KB)
📄
intconv.go
(6.69 KB)
📄
intconv_test.go
(10.01 KB)
📄
intmarsh.go
(2.14 KB)
📄
intmarsh_test.go
(3.07 KB)
📄
link_test.go
(1.4 KB)
📄
nat.go
(26.73 KB)
📄
nat_test.go
(23.56 KB)
📄
natconv.go
(14.55 KB)
📄
natconv_test.go
(16.85 KB)
📄
natdiv.go
(34.15 KB)
📄
prime.go
(10.34 KB)
📄
prime_test.go
(7.1 KB)
📄
rat.go
(13.47 KB)
📄
rat_test.go
(18.89 KB)
📄
ratconv.go
(9.78 KB)
📄
ratconv_test.go
(15.75 KB)
📄
ratmarsh.go
(2.1 KB)
📄
ratmarsh_test.go
(3.3 KB)
📄
roundingmode_string.go
(501 B)
📄
sqrt.go
(2.79 KB)
📄
sqrt_test.go
(4.81 KB)
Editing: floatexample_test.go
// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package big_test import ( "fmt" "math" "math/big" ) func ExampleFloat_Add() { // 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()) fmt.Printf("z = %.10g (%s, prec = %d, acc = %s)\n", &z, z.Text('p', 0), z.Prec(), z.Acc()) // Output: // x = 1000 (0x.fap+10, prec = 64, acc = Exact) // y = 2.718281828 (0x.adf85458248cd8p+2, prec = 53, acc = Exact) // z = 1002.718282 (0x.faadf854p+10, prec = 32, acc = Below) } func ExampleFloat_shift() { // Implement Float "shift" by modifying the (binary) exponents directly. for s := -5; s <= 5; s++ { x := big.NewFloat(0.5) x.SetMantExp(x, x.MantExp(nil)+s) // shift x by s fmt.Println(x) } // Output: // 0.015625 // 0.03125 // 0.0625 // 0.125 // 0.25 // 0.5 // 1 // 2 // 4 // 8 // 16 } func ExampleFloat_Cmp() { inf := math.Inf(1) zero := 0.0 operands := []float64{-inf, -1.2, -zero, 0, +1.2, +inf} fmt.Println(" x y cmp") fmt.Println("---------------") for _, x64 := range operands { x := big.NewFloat(x64) for _, y64 := range operands { y := big.NewFloat(y64) fmt.Printf("%4g %4g %3d\n", x, y, x.Cmp(y)) } fmt.Println() } // Output: // x y cmp // --------------- // -Inf -Inf 0 // -Inf -1.2 -1 // -Inf -0 -1 // -Inf 0 -1 // -Inf 1.2 -1 // -Inf +Inf -1 // // -1.2 -Inf 1 // -1.2 -1.2 0 // -1.2 -0 -1 // -1.2 0 -1 // -1.2 1.2 -1 // -1.2 +Inf -1 // // -0 -Inf 1 // -0 -1.2 1 // -0 -0 0 // -0 0 0 // -0 1.2 -1 // -0 +Inf -1 // // 0 -Inf 1 // 0 -1.2 1 // 0 -0 0 // 0 0 0 // 0 1.2 -1 // 0 +Inf -1 // // 1.2 -Inf 1 // 1.2 -1.2 1 // 1.2 -0 1 // 1.2 0 1 // 1.2 1.2 0 // 1.2 +Inf -1 // // +Inf -Inf 1 // +Inf -1.2 1 // +Inf -0 1 // +Inf 0 1 // +Inf 1.2 1 // +Inf +Inf 0 } func ExampleRoundingMode() { operands := []float64{2.6, 2.5, 2.1, -2.1, -2.5, -2.6} fmt.Print(" x") for mode := big.ToNearestEven; mode <= big.ToPositiveInf; mode++ { fmt.Printf(" %s", mode) } fmt.Println() for _, f64 := range operands { fmt.Printf("%4g", f64) for mode := big.ToNearestEven; mode <= big.ToPositiveInf; mode++ { // sample operands above require 2 bits to represent mantissa // set binary precision to 2 to round them to integer values f := new(big.Float).SetPrec(2).SetMode(mode).SetFloat64(f64) fmt.Printf(" %*g", len(mode.String()), f) } fmt.Println() } // Output: // x ToNearestEven ToNearestAway ToZero AwayFromZero ToNegativeInf ToPositiveInf // 2.6 3 3 2 3 2 3 // 2.5 2 3 2 3 2 3 // 2.1 2 2 2 3 2 3 // -2.1 -2 -2 -2 -3 -3 -2 // -2.5 -2 -3 -2 -3 -3 -2 // -2.6 -3 -3 -2 -3 -3 -2 }
Upload File
Create Folder