FAQ
Just from long standing habit used (type) expr casting when it should be
other way around in Go...
On Fri, Apr 10, 2015 at 10:56 AM, Dave Cheney wrote:

1024 / 1000000 is 0. For the same reason that 1 / 2 is 0. If you want
floating point division, both operands must be floating point types.
On Saturday, 11 April 2015 00:51:54 UTC+10, vlya...@gmail.com wrote:

I have declaration
const SEG_SIZE = 1024
func main() {

msecs := (int) (SEG_SIZE / 1000000) * 1000

supposed to return 1 but it's 0...
Looks like SEG_SIZE / 1000000 always evals to 0 even if i declare msecs
as float64
I can't make any sense of it, can someone help?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 6 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 10, '15 at 2:51p
activeApr 10, '15 at 7:09p
posts6
users5
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase