格式化4.3章中代码格式 (#736)

This commit is contained in:
polunzh
2019-11-16 22:29:07 -06:00
committed by Unknwon
parent c588ddea2d
commit 40a6c2b986

View File

@@ -12,7 +12,7 @@ const Pi = 3.14159
在 Go 语言中,你可以省略类型说明符 `[type]`,因为编译器可以根据变量的值来推断其类型。 在 Go 语言中,你可以省略类型说明符 `[type]`,因为编译器可以根据变量的值来推断其类型。
- 显式类型定义: `const b string = "abc"` - 显式类型定义: `const b string = "abc"`
- 隐式类型定义: `const b = "abc"` - 隐式类型定义: `const b = "abc"`
一个没有指定类型的常量被使用时,会根据其使用环境而推断出它所需要具备的类型。换句话说,未定义类型的常量会在必要时刻根据上下文来获得相关类型。 一个没有指定类型的常量被使用时,会根据其使用环境而推断出它所需要具备的类型。换句话说,未定义类型的常量会在必要时刻根据上下文来获得相关类型。
@@ -32,9 +32,9 @@ f(n + 5) // 无类型的数字型常量 “5” 它的类型在这里变成了 i
数字型的常量是没有大小和符号的,并且可以使用任何精度而不会导致溢出: 数字型的常量是没有大小和符号的,并且可以使用任何精度而不会导致溢出:
```go ```go
const Ln2= 0.693147180559945309417232121458\ const Ln2 = 0.693147180559945309417232121458\
176568075500134360255254120680009 176568075500134360255254120680009
const Log2E= 1/Ln2 // this is a precise reciprocal const Log2E = 1/Ln2 // this is a precise reciprocal
const Billion = 1e9 // float constant const Billion = 1e9 // float constant
const hardEight = (1 << 100) >> 97 const hardEight = (1 << 100) >> 97
``` ```