Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,22 @@
using System;
public static class Program
{
public static void Main() {
Test(100000000000000.01, 100000000000000.011);
Test(100.01, 100.011);
Test(10000000000000.001 / 10000.0, 1000000000.0000001000);
Test(0.001, 0.0010000001);
Test(0.000000000000000000000101, 0.0);
Test(Math.Sqrt(2) * Math.Sqrt(2), 2.0);
Test(-Math.Sqrt(2) * Math.Sqrt(2), -2.0);
Test(3.14159265358979323846, 3.14159265358979324);
void Test(double a, double b) {
const double epsilon = 1e-18;
WriteLine($"{a}, {b} => {a.ApproxEquals(b, epsilon)}");
}
}
public static bool ApproxEquals(this double value, double other, double epsilon) => Math.Abs(value - other) < epsilon;
}