-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C# interactive producing incorrect results #51030
Comments
TimeSpan.FromSeconds(0.0005).Ticks Wish I could see a pattern, but I don't. |
Seems like this is a problem of .NET Framework. using System;
Console.WriteLine(TimeSpan.FromSeconds(0.000005).Ticks);
Console.WriteLine(TimeSpan.FromSeconds(0.00005).Ticks);
Console.WriteLine(TimeSpan.FromSeconds(0.0005).Ticks); The result is 0
0
10000 in net48 and 50
500
5000 in net5.0. In C# Interactive, you can use .NET Core by using > #reset core
Resetting execution engine.
> TimeSpan.FromSeconds(0.00005).Ticks
500 |
https://docs.microsoft.com/en-us/dotnet/api/system.timespan.fromseconds?view=net-5.0 According to the document saying "the specification is accurate to the nearest millisecond", this is by design and the result in .NET 5 is rather incorrect. |
Sounds like this is dotnet/runtime issue then. Hope they choose to update the docs and not revert the change in behavior. I can think of no reason that API shouldn't offer resolution down to the tick for situations like this. Rounding to the millisecond would make it less useful. Anyway, good to know the scope of the issue and that I can continue to depend on the interactive window. Thanks for investigating and thanks for the pointer about "#reset core", wasn't aware of that feature. |
Closing out as this is not an issue with interactive and the underlying cause is known and already tracked with the right team. |
This issue has been moved from a ticket on Developer Community.
[severity:I'm unable to use this version]
The following expression incorrectly returns "0" when evaluated in C# interactive:
TimeSpan.FromSeconds(0.00005). Ticks
It should return 500, as it does when called in a normal .NET process.
If my calculator started producing the wrong values I would throw it in the trash. I don't want to throw C# interactive in the trash.
Original Comments
Feedback Bot on 2/4/2021, 10:16 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Original Solutions
(no solutions)
The text was updated successfully, but these errors were encountered: