FAQ
Check this out: http://play.golang.org/p/2hUOe7xdU3

The second line is what you need.

math.Floor((SEG_SIZE / 1000000.) * 1000)


Two points:

    1. Let compiler know you need a floating division by using 1000000.
    2. Use math.Floor to truncate because Go doesn't allow conversion of
    constants with accuracy loss.


David
On Friday, April 10, 2015 at 7:51:54 AM UTC-7, 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

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 6 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