Why approxEqual not working for integers in dmd 2068-b2
lobo via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 27 19:16:56 PDT 2015
Hi all,
I have a bunch of unittests for template code taking any numeric
type. Because I'm lazy I just use the approxEqual for both
floating point and integer comparisons in these tests.
In DMD 2067.1 everthing compiled OK but in 2068-b2 I get the
errors shown at the end of this post for integer types.
I'd like to know if it is OK to use approxEqual like I am in
unittests and why approxEqual was changed, if it was intentional,
for learning more about good use of D language
Thanks,
lobo
Test code:
---
void main() {
int a = 10;
assert(approxEqual(10, a));
}
---
Errors:
src/phobos/std/math.d(6718): Error: std.math.fabs called with
argument types (int) matches both:
src/phobos/std/math.d(3415): std.math.fabs(real x)
and:
/src/phobos/std/math.d(3421): std.math.fabs(float x)
/src/phobos/std/math.d(6725): Error: std.math.fabs called with
argument types (int) matches both:
/src/phobos/std/math.d(3415): std.math.fabs(real x)
and:
/src/phobos/std/math.d(3421): std.math.fabs(float x)
/src/phobos/std/math.d(6726): Error: std.math.fabs called with
argument types (int) matches both:
/src/phobos/std/math.d(3415): std.math.fabs(real x)
and:
/src/phobos/std/math.d(3421): std.math.fabs(float x)
/src/phobos/std/math.d(6736): Error: template instance
std.math.approxEqual!(int, int, double) error instantiating
hack.d(13): instantiated from here: approxEqual!(int, int)
Failed: ["dmd", "-v", "-o-", "hack.d", "-I."]
---
More information about the Digitalmars-d-learn
mailing list