diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-02-12 16:47:14 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-12 16:47:14 -0500 |
| commit | f07834e19a34d5f9c03d681083b5ba30e262889d (patch) | |
| tree | ad0b29fe3de15cad85ba6ecfa6bd35115ab34785 /tools | |
| parent | e1e7a6eec04ee1d04dc7e0d0212208d4c7a9592b (diff) | |
Nvrtc disable warnings/Float literal improvements (#1220)
* Added 'truncate' for fixing floats, for floats near the max value (as opposed to making infinite).
Put AreNearlyEqual into Math
* Test for ::make static method.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/slang-test/slang-test-main.cpp | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index 165f7a322..79cd6c1a7 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -2012,34 +2012,6 @@ static double _textToDouble(const UnownedStringSlice& slice) return atof(buffer); } -static bool _areNearlyEqual(double a, double b, double epsilon) -{ - // If they are equal then we are done - if (a == b) - { - return true; - } - - const double absA = Math::Abs(a); - const double absB = Math::Abs(b); - const double diff = Math::Abs(a - b); - - // https://en.wikipedia.org/wiki/Double_precision_floating-point_format - // - const double minNormal = 2.2250738585072014e-308; - - // Either a or b are very close to being zero, so doing relative comparison isn't really appropriate - if (a == 0.0 || b == 0.0 || (absA + absB < minNormal)) - { - return diff < (epsilon * minNormal); - } - else - { - // Calculate a relative relative error - return diff < epsilon * (absA + absB); - } -} - static void _calcLines(const UnownedStringSlice& slice, List<UnownedStringSlice>& outLines) { StringUtil::calcLines(slice, outLines); @@ -2125,7 +2097,7 @@ static SlangResult _compareWithType(const UnownedStringSlice& actual, const Unow double valueA = _textToDouble(lineActual); double valueB = _textToDouble(lineRef); - if (!_areNearlyEqual(valueA, valueB, differenceThreshold)) + if (!Math::AreNearlyEqual(valueA, valueB, differenceThreshold)) { return SLANG_FAIL; } |
