LoginSignup
10
7

More than 5 years have passed since last update.

Go の浮動小数点型の割り算

Last updated at Posted at 2013-06-17

問題: 次の出力はなんでしょう?

package main

import (
        "fmt"
)

func main() {
        fmt.Printf("%v\n", 1.0 / 2)
        i := 2
        fmt.Printf("%v\n", 1.0 / i)
}

答え:

0.5
0

これに一時間くらいハマった。

追記: 仕様らしい: https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/BtdivXuo2-o

10
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
7