Skip to content

System.Single.ToString() behavior changed from netcoreapp2.2 to netcoreapp3.0 (returns "-0") #32237

@bencameron

Description

@bencameron
class Program
{
	static void Main(string[] args)
	{
		var foo = new Foo();
		var barString = foo.Bar.ToString();
		var negBarString = foo.NegativeBar.ToString();
		var ver = Assembly.GetEntryAssembly()?
			.GetCustomAttribute<TargetFrameworkAttribute>()?.FrameworkName;

		Console.WriteLine($"Target Framework: {ver}");
		Console.WriteLine($"Bar: {barString}");
		Console.WriteLine($"NegativeBar: {negBarString}");
	}

	private class Foo
	{
		public float Bar => 0f;
		public float NegativeBar => -Bar;
	}
}

Results:
image

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.NumericsquestionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions