Skip to content
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

BigInteger.TryParse incorrectly parses "80000000" from hex as -4294967295 #54251

Closed
rjmholt opened this issue Jun 15, 2021 · 3 comments
Closed

Comments

@rjmholt
Copy link

rjmholt commented Jun 15, 2021

Description

From PowerShell/PowerShell#15587.

Possibly related to #50385?

However, in this case this behaviour represents a regression from .NET 6 preview 5.

Repro:

using System;
using System.Diagnostics;
using System.Globalization;
using System.Numerics;
using System.Runtime.InteropServices;

namespace repro
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine($".NET: '{RuntimeInformation.FrameworkDescription}'");

            string numStr = args.Length > 0
                ? args[0]
                : "80000000";

            BigInteger.TryParse(numStr, NumberStyles.AllowHexSpecifier, NumberFormatInfo.InvariantInfo, out BigInteger bi);

            Console.WriteLine($"Expected: '{numStr}'");
            Console.WriteLine($"Actual: '{bi.ToString("X")}'");

            Debug.Assert(bi.ToString("X") == numStr);
        }
    }
}

Configuration

x64 Windows PC:

OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.19043 N/A Build 19043
> dotnet version
6.0.100-preview.5.21302.13

Regression?

This previously worked in .NET 6 preview 4.

Other information

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Jun 15, 2021
@ghost
Copy link

ghost commented Jun 16, 2021

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

From PowerShell/PowerShell#15587.

Possibly related to #50385?

However, in this case this behaviour represents a regression from .NET 6 preview 5.

Repro:

using System;
using System.Diagnostics;
using System.Globalization;
using System.Numerics;
using System.Runtime.InteropServices;

namespace repro
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine($".NET: '{RuntimeInformation.FrameworkDescription}'");

            string numStr = args.Length > 0
                ? args[0]
                : "80000000";

            BigInteger.TryParse(numStr, NumberStyles.AllowHexSpecifier, NumberFormatInfo.InvariantInfo, out BigInteger bi);

            Console.WriteLine($"Expected: '{numStr}'");
            Console.WriteLine($"Actual: '{bi.ToString("X")}'");

            Debug.Assert(bi.ToString("X") == numStr);
        }
    }
}

Configuration

x64 Windows PC:

OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.19043 N/A Build 19043
> dotnet version
6.0.100-preview.5.21302.13

Regression?

This previously worked in .NET 6 preview 4.

Other information

Author: rjmholt
Assignees: -
Labels:

area-System.Numerics, untriaged

Milestone: -

jfd16 added a commit to jfd16/runtime that referenced this issue Jun 16, 2021
@tannergooding tannergooding added bug and removed untriaged New issue has not been triaged by the area owner labels Jun 16, 2021
@tannergooding tannergooding added this to the 6.0.0 milestone Jun 17, 2021
@rjmholt
Copy link
Author

rjmholt commented Jul 14, 2021

Looks like this was fixed in #54262.

@rjmholt rjmholt closed this as completed Jul 14, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants