|
15 | 15 | package math_test
|
16 | 16 |
|
17 | 17 | import (
|
| 18 | + "fmt" |
18 | 19 | "testing"
|
19 | 20 |
|
20 | 21 | "cuelang.org/go/pkg/internal/builtintest"
|
| 22 | + "cuelang.org/go/pkg/math" |
21 | 23 | )
|
22 | 24 |
|
23 | 25 | func TestBuiltin(t *testing.T) {
|
24 | 26 | builtintest.Run("math", t)
|
25 | 27 | }
|
| 28 | + |
| 29 | +func Example_constants() { |
| 30 | + show := func(name string, value any) { |
| 31 | + fmt.Printf("% 7s: %v\n", name, value) |
| 32 | + } |
| 33 | + |
| 34 | + show("E", math.E) |
| 35 | + show("Pi", math.Pi) |
| 36 | + show("Phi", math.Phi) |
| 37 | + |
| 38 | + show("Sqrt2", math.Sqrt2) |
| 39 | + show("SqrtE", math.SqrtE) |
| 40 | + show("SqrtPi", math.SqrtPi) |
| 41 | + show("SqrtPhi", math.SqrtPhi) |
| 42 | + |
| 43 | + show("Ln2", math.Ln2) |
| 44 | + show("Log2E", math.Log2E) |
| 45 | + show("Ln10", math.Ln10) |
| 46 | + show("Log10E", math.Log10E) |
| 47 | + |
| 48 | + // Output: |
| 49 | + // E: 2.718281828459045 |
| 50 | + // Pi: 3.141592653589793 |
| 51 | + // Phi: 1.618033988749895 |
| 52 | + // Sqrt2: 1.4142135623730951 |
| 53 | + // SqrtE: 1.6487212707001282 |
| 54 | + // SqrtPi: 1.772453850905516 |
| 55 | + // SqrtPhi: 1.272019649514069 |
| 56 | + // Ln2: 0.6931471805599453 |
| 57 | + // Log2E: 1 |
| 58 | + // Ln10: 2.302585092994046 |
| 59 | + // Log10E: 0 |
| 60 | +} |
0 commit comments