Re: [go-nuts] Possible optimization bug in go1.8?

2017-05-08 Thread peterGo
Ryan, It's not weird. https://play.golang.org -> About In the playground the time begins at 2009-11-10 23:00:00 UTC (determining the significance of this date is an exercise for the reader). This makes it easier to cache programs by giving them deterministic output. Peter On Monday, May 8,

Re: [go-nuts] Possible optimization bug in go1.8?

2017-05-08 Thread Decker, Ryan C.
See here: https://play.golang.org/p/EjdQRUnwQF The weird thing is that time.Now().UnixNano() doesn't appear to ever change in the playground... On Mon, May 8, 2017 at 10:21 AM, Decker, Ryan C. wrote: > I usually follow the example and go with time.Now().UnixNano() which you

Re: [go-nuts] Possible optimization bug in go1.8?

2017-05-08 Thread Decker, Ryan C.
I usually follow the example and go with time.Now().UnixNano() which you can see here: On Mon, May 8, 2017 at 10:07 AM, messju mohr wrote: > Hi, > > in xrand() you are initialising r with the same constant seed for > every call, so you always get the same pseudo

Re: [go-nuts] Possible optimization bug in go1.8?

2017-05-08 Thread shabinesh sivaraj
Thank you all for replying. I get it now. On 8 May 2017 8:20 pm, "messju mohr" wrote: > > It's not strange, it's intended behaviour of the playground. See the > "about" page of the playground: > "[...] In the playground the time begins at 2009-11-10 23:00:00 UTC >

Re: [go-nuts] Possible optimization bug in go1.8?

2017-05-08 Thread messju mohr
It's not strange, it's intended behaviour of the playground. See the "about" page of the playground: "[...] In the playground the time begins at 2009-11-10 23:00:00 UTC (determining the significance of this date is an exercise for the reader). This makes it easier to cache programs by giving

Re: [go-nuts] Possible optimization bug in go1.8?

2017-05-08 Thread messju mohr
Hi, in xrand() you are initialising r with the same constant seed for every call, so you always get the same pseudo random number. See: cheers messju On Mon, May 08, 2017 at 03:26:08AM -0700, sivarajshabin...@gmail.com wrote: >Hi All, > >

Re: [go-nuts] Possible optimization bug in go1.8?

2017-05-08 Thread 'chris dollin' via golang-nuts
Every call of xrand calls .Int() on a fresh generator initialised the same way as the previous one, so it will give the same result. The calls to .Int() in main are all on the /same/ generator, which is updated by each call, so you get three different values. Chris On 8 May 2017 at 11:26,

Re: [go-nuts] Possible optimization bug in go1.8?

2017-05-08 Thread Jan Mercl
On Mon, May 8, 2017 at 3:50 PM wrote: > Could it be a bug? No, the xrand function will always return the same number. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

[go-nuts] Possible optimization bug in go1.8?

2017-05-08 Thread sivarajshabinesh
Hi All, Firstly, sorry for the title that sounds like a click bait. I am not understanding what exactly is wrong with this program https://play.golang.org/p/Tl0wpaCqK7 package main import ( "fmt" "math/rand" "runtime" ) func xrand() int { r := rand.New(rand.NewSource(99))