Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upMath.Cos(double.MaxValue) returns different values on Windows and other platforms #4318
Comments
mellinoe
added this to the 1.0.0-rtm milestone
Apr 13, 2016
mellinoe
referenced this issue
Apr 13, 2016
Closed
Inconsistent results for Math.Cos(double.MaxValue) on Windows and non-Windows platforms #6022
gkhanna79
added
the
bug
label
Apr 14, 2016
gkhanna79
assigned
janvorli
Apr 14, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@janvorli PTAL |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
janvorli
Apr 14, 2016
Member
Here is top of the call stack of the Math.Cos invocation on Linux:
* frame #0: 0x00007ffff73cacf0 libm.so.6`???
frame #1: 0x00007ffff6624df1 libcoreclr.so`COMDouble::Cos(d=1.7976931348623157E+308) + 49 at floatnative.cpp:147
and here is the source:
FCIMPL1_V(double, COMDouble::Cos, double d)
FCALL_CONTRACT;
return (double) cos(d);
FCIMPLENDSo the behavior clearly reflects the C++ math library cos behavior on each platform.
I would prefer keeping it as is instead of adding the overhead of simulating the windows behavior.
|
Here is top of the call stack of the Math.Cos invocation on Linux:
and here is the source: FCIMPL1_V(double, COMDouble::Cos, double d)
FCALL_CONTRACT;
return (double) cos(d);
FCIMPLENDSo the behavior clearly reflects the C++ math library |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mellinoe
Apr 14, 2016
Contributor
Yes, this is what I expected to be the cause, but it's good to have confirmation. I am fine with this behavior difference as well, but I wanted to call it out to make sure it had seen some scrutiny other than my own. I'm not sure if we have a list of such low-level behavioral differences, but if we do we should document this one.
|
Yes, this is what I expected to be the cause, but it's good to have confirmation. I am fine with this behavior difference as well, but I wanted to call it out to make sure it had seen some scrutiny other than my own. I'm not sure if we have a list of such low-level behavioral differences, but if we do we should document this one. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
janvorli
Apr 14, 2016
Member
I am not aware of such a list. @richlander do we have some doc where a list of platform specific differences as @mellinoe has suggested would fit?
|
I am not aware of such a list. @richlander do we have some doc where a list of platform specific differences as @mellinoe has suggested would fit? |
sergiy-k
modified the milestones:
1.1.0,
1.0.0-rtm
May 5, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
gkhanna79
Oct 13, 2016
Member
@leecow @blackdwarf Can you please add this to the documented difference list we prepare for each release?
|
@leecow @blackdwarf Can you please add this to the documented difference list we prepare for each release? |
gkhanna79
assigned
blackdwarf
Oct 13, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
janvorli
Oct 25, 2016
Member
I can see a reference to this issue was added to https://github.com/dotnet/core/blob/master/release-notes/1.1/1.1.0-preview1-known-issues.md, so I am closing this issue.
|
I can see a reference to this issue was added to https://github.com/dotnet/core/blob/master/release-notes/1.1/1.1.0-preview1-known-issues.md, so I am closing this issue. |
janvorli
closed this
Oct 25, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
omajid
Nov 18, 2016
Member
Would adding a math library that has matching results on all platforms be worth it? Java has a StrictMath (separate from the regular Math) class that requires implementations to return values that match published algorithms.
|
Would adding a math library that has matching results on all platforms be worth it? Java has a |
mellinoe commentedApr 13, 2016
Scenario:
Expected behavior
double.MaxValue is returned according to the .NET Framework documentation:
Actual behavior
on Windows,
double.MaxValueis returned. On my Ubuntu test machine, -0.999987689... is returned.This may be an acceptable difference in behavior, as long as we've acknowledged it. It seems like we could easily match this behavior by doing some parameter boundary checks, but it may not be worth it. I'm assuming this behavior difference is coming from the native cosine functions we are using.