docker/docker — pull request #9233 by inatatsu (2014-11-19 10:07:58+00:00)
Title: Fix to avoid a compile error due to float to int truncation with GCCGO

The unit test `pkg/units/size_test.go` fails with GCCGO due to a compilation error:
```
inagaki@black3:~/upstream/src/github.com/docker/docker/pkg/units$ go version
go version gccgo (GCC) 5.0.0 20141029 (experimental) linux/amd64
inagaki@black3:~/upstream/src/github.com/docker/docker/pkg/units$ go test
# _/home/inagaki/upstream/src/github.com/docker/docker/pkg/units
./size_test.go:28:43: error: floating point constant truncated to integer
assertEquals(t, "2.22 PB", HumanSize(2.22*PB))
^
FAIL _/home/inagaki/upstream/src/github.com/docker/docker/pkg/units [build failed]
inagaki@black3:~/upstream/src/github.com/docker/docker/pkg/units$
```
According to [the discussion on GCC Bugzilla](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63812#c3), this is due to the difference between GCCGO and GC in the implementations of floating point constant expression. The [language](http://golang.org/ref/spec#Constant_expressions) specifies that a compiler raises an error when a floating point constant expression is truncated to integer, a precision of the internal representation is implementation-dependent. While my workaround is modifying `size_test.go` as:
```
assertEquals(t, "2.22 PB", HumanSize(int64(float64(2.22*PB))))
```
, is it better to modify the parameter of `HumanSize()` from `int64` to `float64` like `BytesSize()`?
Signed-off-by: Tatsushi Inagaki