Re: [go-nuts] Possible issue with math.Floor on Linux

2018-05-05 Thread Andrei Avram
Indeed, it was about precision, the issue is with Windows, not with Go. I've used only one time.Now call and the planets have aligned. package main import ( "time" "math" "fmt" ) func main() { now := time.Now() datetime := now.Add(time.Hour * 24 * 7 * 4 * 12 * 3) seconds := -1 * int(now.Sub(da

Re: [go-nuts] Possible issue with math.Floor on Linux

2018-05-04 Thread Andrei Avram
Yes, this could be it. First I was fooled by println rounding 2.9 to 3, thinking floor is not working properly on Linux. Thanks! On Saturday, May 5, 2018 at 1:49:34 AM UTC+3, Steven Hartland wrote: > > You could be seeing a side effect on fact that windows only ticks every > 15ms. > > On Fri, 4

Re: [go-nuts] Possible issue with math.Floor on Linux

2018-05-04 Thread Steven Hartland
You could be seeing a side effect on fact that windows only ticks every 15ms. On Fri, 4 May 2018 at 21:56, Andrei Avram wrote: > This code is extracted from something real. Someone on the team noticed > the unit tests (which I wrote on a Linux machine) were failing on their > Windows machine. >

Re: [go-nuts] Possible issue with math.Floor on Linux

2018-05-04 Thread Andrei Avram
This code is extracted from something real. Someone on the team noticed the unit tests (which I wrote on a Linux machine) were failing on their Windows machine. I'll continue studying this and come back if I find something new. Thank you both for your time, I appreciate it! On Friday, May 4, 20

Re: [go-nuts] Possible issue with math.Floor on Linux

2018-05-04 Thread speter
To file a bug (and have it treated seriously) you would need to demonstrate that it is causing problems in a program that actually does something useful, not just a pathological code sample. My expectation would be that once you start doing some real processing, the difference between time.Now() in

Re: [go-nuts] Possible issue with math.Floor on Linux

2018-05-04 Thread Andrei Avram
> > But I don't think it is because Windows is so much faster than Linux > Yeah... :) I was exploring all cases. and/or the way the time package implemented is different between Windows > and Linux Could this be considered a possible Go bug and would it worth opening an issue on Github?

Re: [go-nuts] Possible issue with math.Floor on Linux

2018-05-04 Thread speter
So on Linux it's working as expected. In the playground time is "virtual"; the start time is fixed and it doesn't progress unless you explicitly Sleep -- because you don't Sleep in your program, time.Now() returns the same time on both invocation. So the only slightly surprising part is that on Wi

Re: [go-nuts] Possible issue with math.Floor on Linux

2018-05-04 Thread Andrei Avram
Peter and Ian, you are both wright regarding the printing. Still, on Linux I have different values than on Go Playground. Regarding the speed, Peter, do you think that on Windows the two calls just run faster every time? On Friday, May 4, 2018 at 9:07:15 PM UTC+3, speter wrote: > > b is slightl

Re: [go-nuts] Possible issue with math.Floor on Linux

2018-05-04 Thread speter
b is slightly less than 3 because there is a bit of time between the two calls to time.Now(). If you substitute this: fmt.Printf("input: %20.18f\n", b) you get something like input: 2.99965553350911 HTH Peter On Fri, May 4, 2018 at 7:26 PM, Andrei Avram wrote: > Hello everyone, >

Re: [go-nuts] Possible issue with math.Floor on Linux

2018-05-04 Thread Ian Lance Taylor
On Fri, May 4, 2018 at 10:26 AM, Andrei Avram wrote: > > Today I ran into a situation that is strange to me. I ran the following code > on two Linux machines (go run floor.go), on two Windows ones, and on Go > Playground. > > package main > > import ( > "time" > "math" > ) > > func main() { > date

[go-nuts] Possible issue with math.Floor on Linux

2018-05-04 Thread Andrei Avram
Hello everyone, Today I ran into a situation that is strange to me. I ran the following code on two Linux machines (go run floor.go), on two Windows ones, and on Go Playground. package main import ( "time" "math" ) func main() { datetime := time.Now().Add(time.Hour * 24 * 7 * 4 * 12 * 3) seco