Skip to content

Instantly share code, notes, and snippets.

@gm50x
Created April 25, 2020 20:35
Show Gist options
  • Save gm50x/4b0a78987712ec453e797d3a4fe6c22b to your computer and use it in GitHub Desktop.
Save gm50x/4b0a78987712ec453e797d3a4fe6c22b to your computer and use it in GitHub Desktop.
/**
* Demonstrates Imprecision in C# floats running on top of .NET Core 3.1
**/
using System;
public class Program
{
public static void Main()
{
float n = 1.00f;
while (n > 0) {
float m = n;
n = n - 0.01f;
Console.WriteLine($"{m} - {0.01f} = {n}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment