Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Fixing up various roundtripping/serialization tests that are impacted by the double/single tostring and parse changes #32268

Closed
wants to merge 2 commits into from

Conversation

tannergooding
Copy link
Member

This fixes up all the tests that are impacted by dotnet/coreclr#19905

@tannergooding tannergooding changed the title Ieee tostring Fixing up various roundtripping/serialization tests that are impacted by the double/single tostring and parse changes Sep 13, 2018
@danmoseley
Copy link
Member

Is this para in the number formatting doc still accurate "For Double values, the "R" format specifier in some cases fails to successfully round-trip the original value. For both Double and Single values, it also offers relatively poor performance. Instead, we recommend that you use the "G17" format specifier for Double values and the "G9" format specifier to successfully round-trip Single values."

@danmoseley
Copy link
Member

BTW is round tripping ever unstable, ie, round trip the output again and you get a third value

}

[Theory]
[InlineData(1.1, "1.1000000000000001")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So previously round-tripping "1.1" with "R" gave "1.1" and after this change it gives "1.1000...01"? And that is because we changed the algorithm to give better round tripping in other cases? Even if it is a strict improvement in more cases we will definitely get bug reports.. Cc @jkotas

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the IEEE spec requires you to return the full set of digits (9 for single and 17 for double) in order to guarantee the number can always round-trip successfully.

We are going to be getting bugs either way. We already had a number of issues related to parsing, formatting, and round-tripping values behaving incorrectly: dotnet/coreclr#1316, dotnet/coreclr#3313, dotnet/coreclr#13106, dotnet/coreclr#13615, dotnet/coreclr#16783, dotnet/coreclr#17467 (with even more issues on stackoverflow, uservoice, etc)

Many of these issues have caused people to write their own implementations (such as Roslyn) or provide their own workarounds (such as various bits of serialization code in CoreFX).

For round-tripping specifically, any effort to provide "prettier" numbers will slow down the implementation and is going to be prone to bugs (as was the case already). However, as part of the updates to make things more IEEE compliant, users will have expanded capabilities that will let them get correct results in the format they desire.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For round-tripping specifically, any effort to provide "prettier" numbers will slow down the implementation

The "prettier" number are shorter strings. If you give me 6x longer string for 1.1 than required, I have to send 6x more bytes over the wire. Unclear whether there is anything actually saved at the end - depends on a lot of factors.

{
var objs = new RectangleF[]
{
new RectangleF(1.50001f, -2.5000f, 1.5000f, -2.5000f)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe that's how VS does it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the badly formatted code here was just copied verbatim from the existing testcase that covers netfx.

A good bit of the code could do with cleanup/refactoring.

@tannergooding
Copy link
Member Author

Is this para in the number formatting doc still accurate "For Double values, the "R" format specifier in some cases fails to successfully round-trip the original value. For both Double and Single values, it also offers relatively poor performance. Instead, we recommend that you use the "G17" format specifier for Double values and the "G9" format specifier to successfully round-trip Single values.

The docs will need updated in a few places. I indicated as such here: dotnet/coreclr#19905 (comment)

@tannergooding
Copy link
Member Author

BTW is round tripping ever unstable, ie, round trip the output again and you get a third value

No, roundtripping should be completely stable.

@tannergooding
Copy link
Member Author

Closing this for the time being. Will re-open after the corresponding CoreCLR PR gets cleaned up.

@karelz karelz added this to the 3.0 milestone Oct 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants