Skip to content

Instantly share code, notes, and snippets.

@0xced
Created July 3, 2020 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xced/e79a3ae7216528752b2c2663a4e9a158 to your computer and use it in GitHub Desktop.
Save 0xced/e79a3ae7216528752b2c2663a4e9a158 to your computer and use it in GitHub Desktop.
Formatting of -0 in .NET Core
using System;
using System.Globalization;
static class Program
{
private static void Main()
{
static string FormatCoordinate(double x, double y) => $"({x.ToString(NumberFormatInfo.InvariantInfo)},{y.ToString(NumberFormatInfo.InvariantInfo)})";
const double a = 0;
const double b = 0;
Console.WriteLine(FormatCoordinate(0, -0));
Console.WriteLine(FormatCoordinate(a, -b));
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment