So we need to fixed the comparisons on the dewalls library. On Fri, Mar 9, 2018 at 2:24 PM Philip Schuchardt <vpica...@gmail.com> wrote:
> Wow, we were using long doubles before. I don't think we need that much > precision for cave survey. In catch there is Approx() that should take care > of floating point comparison correctly. > > On Fri, Mar 9, 2018 at 11:30 AM Wookey <woo...@wookware.org> wrote: > >> A bit of research tells that using 'long double' causes 80-bit fp on x86 >> (i386 and amd64), as opposed to the 64-bit IEE 754 fp representation used >> on other platforms, which is what you get if you specify double. >> >> So I tried changing the angle.{cpp.h} code to use double instead of long >> double. >> >> That doesn't fix the problrematic tests, but does cause another 43 to >> fail: >> test cases: 8 | 3 passed | 5 failed >> assertions: 202 | 155 passed | 47 failed >> >> They all fail equality tests, despite them clearly being 'equal >> enough' for our purposes. >> >> e.g. >> /home/wookey/dewalls-1.0.0+ds1/test/azimuthparsingtests.cpp:31: FAILED: >> CHECK( WallsSurveyParser("5:4").azimuth(Angle::Degrees) == UAngle(5 + 4 >> / 60.0, Angle::Degrees) ) >> with expansion: >> 5.06667 deg == 5.06667 deg >> >> I see that 'approx' is used in the codebase which you might hope would >> get all this right, but clearly excessive precision is being used for >> our purposes (cave survey data). >> >> I'm not sure how to fix this. >> >> I've done an upload in the meantime with the previous bodge of the >> tests, and to fix another bug too and let the package migrate to >> testing. But getting the codebase to do what we actually expect would >> be good. >> >> This is the patch I used to try double for angles: >> >> Author: Wookey <woo...@debian.org> >> Last-Update: 2018-03-09 >> >> --- dewalls-1.0.0+ds1.orig/src/angle.cpp >> +++ dewalls-1.0.0+ds1/src/angle.cpp >> @@ -3,13 +3,13 @@ >> >> namespace dewalls { >> >> -const long double PI = acosl(-1.0L); >> -const long double DegreesToRadians = PI / 180.0L; >> -const long double GradiansToRadians = PI / 200.0L; >> -const long double MilsNATOToRadians = PI / 3200.0L; >> -const long double RadiansToDegrees = 180.0L / PI; >> -const long double RadiansToGradians = 200.0L / PI; >> -const long double RadiansToMilsNATO = 3200.0L / PI; >> +const double PI = acosl(-1.0L); >> +const double DegreesToRadians = PI / 180.0L; >> +const double GradiansToRadians = PI / 200.0L; >> +const double MilsNATOToRadians = PI / 3200.0L; >> +const double RadiansToDegrees = 180.0L / PI; >> +const double RadiansToGradians = 200.0L / PI; >> +const double RadiansToMilsNATO = 3200.0L / PI; >> >> QString Angle::Name("angle"); >> >> @@ -30,7 +30,7 @@ QString Angle::symbolFor(Unit unit) { >> } >> } >> >> -long double Angle::toBase(long double quantity, Unit fromUnit) { >> +double Angle::toBase(double quantity, Unit fromUnit) { >> switch (fromUnit) { >> case Radians: >> return quantity; >> @@ -47,7 +47,7 @@ long double Angle::toBase(long double qu >> } >> } >> >> -long double Angle::fromBase(long double quantity, Unit toUnit) { >> +double Angle::fromBase(double quantity, Unit toUnit) { >> switch (toUnit) { >> case Radians: >> return quantity; >> @@ -64,7 +64,7 @@ long double Angle::fromBase(long double >> } >> } >> >> -long double Angle::convert(long double quantity, Unit fromUnit, Unit >> toUnit) { >> +double Angle::convert(double quantity, Unit fromUnit, Unit toUnit) { >> return fromBase(toBase(quantity, fromUnit), toUnit); >> } >> >> --- dewalls-1.0.0+ds1.orig/src/angle.h >> +++ dewalls-1.0.0+ds1/src/angle.h >> @@ -21,9 +21,9 @@ public: >> >> static QString Name; >> >> - static long double toBase(long double quantity, Unit fromUnit); >> - static long double fromBase(long double quantity, Unit toUnit); >> - static long double convert(long double quantity, Unit fromUnit, Unit >> toUnit); >> + static double toBase(double quantity, Unit fromUnit); >> + static double fromBase(double quantity, Unit toUnit); >> + static double convert(double quantity, Unit fromUnit, Unit toUnit); >> static QString symbolFor(Unit unit); >> }; >> >> >> >> Wookey >> -- >> Principal hats: Linaro, Debian, Wookware, ARM >> http://wookware.org/ >> > -- > Phi|ip > -- Phi|ip