Browse Source

floatToInt

master
dewjjj 8 months ago
parent
commit
3e1bab71a9
  1. 1
      README.md
  2. 12
      floatToInt/floatToInt.go

1
README.md

@ -19,3 +19,4 @@
| 15 | popcount&test | 置位数量 |
| 16 | int | 整型越界 |
| 17 | bitwise | 位运算符 |
| 18 | floatToInt | 浮点数损失 |

12
floatToInt/floatToInt.go

@ -0,0 +1,12 @@
package main
import "fmt"
func main() {
f := 3.1415296
i := int(f)
fmt.Println(f, i)
g := -3.9415296
i = int(g)
fmt.Println(g, i)
}
Loading…
Cancel
Save