File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 4
4
package main
5
5
6
6
import "fmt"
7
+ import "math"
7
8
8
9
// `const` declares a constant value.
9
10
const s string = "constant"
@@ -18,15 +19,15 @@ func main() {
18
19
// Constant expressions perform arithmetic with
19
20
// arbitrary precision.
20
21
const d = 3e20 / n
22
+ fmt .Println (d )
21
23
22
24
// A numeric constant has no type until it's given
23
25
// one, such as by an explicit cast.
24
26
fmt .Println (int64 (d ))
25
27
26
- // A number can also be given a type by using it in a
28
+ // A number can be given a type by using it in a
27
29
// context that requires one, such as a variable
28
- // assignment or function call. The type it gets
29
- // depends on its value.
30
- fmt .Println (n ) // int
31
- fmt .Println (d ) // float64
30
+ // assignment or function call. For example, here
31
+ // `math.Sin` expects a `float64`.
32
+ fmt .Println (math .Sin (n ))
32
33
}
You can’t perform that action at this time.
0 commit comments