#41597: std::remquo does not yield the proper result for the quotient Open Date: 2021-02-17 21:25 Last Update: 2021-02-24 21:15 URL for this Ticket: https://osdn.net//projects/mingw/ticket/41597 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=41597 --------------------------------------------------------------------- Last Changes/Comment on this Ticket: 2021-02-24 21:15 Updated by: keith Comment: Addendum To keith I've fixed it, ... I'll update the patch, to reflect the correction, shortly. Done. The difference, w.r.t. the preceding patch, is effectively: $ hg diff diff --git a/mingwrt/mingwex/math/remquo_generic.sx b/mingwrt/mingwex/math/remquo_generic.sx --- a/mingwrt/mingwex/math/remquo_generic.sx +++ b/mingwrt/mingwex/math/remquo_generic.sx @@ -90,12 +90,12 @@ */ .globl _remquol .def _remquol; .scl 2; .type 32; .endef _remquol: - fld DWORD ptr 4[esp] /* FPU TOS = x */ - fld DWORD ptr 16[esp] /* FPU TOS = y, x */ + fld TBYTE ptr 4[esp] /* FPU TOS = x */ + fld TBYTE ptr 16[esp] /* FPU TOS = y, x */ mov edx, DWORD ptr 28[esp] /* EDX = *q */ /* Hand off the preloaded register set, to the shared computational * back-end routine, to... */ --------------------------------------------------------------------- Ticket Status: Reporter: avhaecke Owner: keith Type: Issues Status: Open [Owner assigned] Priority: 5 - Medium MileStone: (None) Component: WSL Severity: 5 - Medium Resolution: None --------------------------------------------------------------------- Ticket details: Context : This problem was encountered with gcc on MinGW in the following version : gcc.exe (MinGW.org GCC-6.3.0-1) 6.3.0 Description : The following code : double numer = 90.1 ; double denom = 90 .0 ; int quot ; double result = std::remquo(numer, denom, ") ; std::cout << "result " << result << std::endl ; std::cout << "quot " << quot << std::endl;should yield : result 0.1 quot 1 As is expected from std::remquo, quot has a magnitude which should be congruent (modulo 2 to the nth) to the magnitude of the integral quotient of x/y, n being greater or equal than 3. However with gcc 6.3.0, on MinGW, the above instructions yield : result 0.1 quot 0 On another version of gcc (gcc 4.9.1 2014), the expected behavior is encountered. -- Ticket information of MinGW - Minimalist GNU for Windows project MinGW - Minimalist GNU for Windows Project is hosted on OSDN Project URL: https://osdn.net/projects/mingw/ OSDN: https://osdn.net URL for this Ticket: https://osdn.net/projects/mingw/ticket/41597 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=41597