## ◆ remquo()

 std::pair > boost::simd::remquo ( IEEEValue const & x, IEEEValue const & y )

This function object computes the remainder (rem) and a part of the quotient (quo) upon division of x by y.

By design, the value of the remainder is the same as that computed by the rem standard function. The value of the computed quotient has the sign of x/y and agrees with the actual quotient in at least the low order 3 bits.

semantic:

If T is the common type to x and y

std::pair< T, as_integer_t<T> > p = remquo(x, y);

computes the two values.

Note
• This function mimics a standard C library one that was mainly written in its time to help computation of periodic trigonometric functions: three bits of quo allowing to know the 'octant'
• This implementation differs from std::remquo as the quotient is not returned as a pointer, and his type is not int but the signed integer type associated to the floating one, to allow proper SIMD implementation.
• also note that the double implementation of std::remquo is flawed in GNU C Library until version 2.21 (2.22 has been corrected).
Example:
#include <boost/simd/arithmetic.hpp>
#include <boost/simd/pack.hpp>
#include <boost/simd/constant/valmax.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 4>;
int main()
{
pack_ft xf = { 3.0f, -2.0f, -3.0f, 1.0f };
pack_ft yf = { 4.0f, -1.0f, -3.0f, 2.0f };
pack_ft rf;
pack_it qi;
std::tie(rf, qi) = bs::remquo(xf, yf);
std::cout
<< "---- simd: std::tie(xf, yf) = bs::remquo(xf, yf)\n"
<< " <- xf = " << xf << '\n'
<< " <- yf = " << yf << '\n'
<< " -> rf = " << rf << '\n'
<< " -> qi = " << qi << '\n';
float sxf = 3.0f, syf = 4.0f;
float srf;
std::int32_t sqi;
std::tie(srf, sqi) = bs::remquo(sxf, syf);
std::cout
<< "---- scalar: std::tie(srf, sqi) = bs::remquo(sxf, syf)\n"
<< " <- sxf = " << sxf << '\n'
<< " <- syf = " << syf << '\n'
<< " -> srf = " << srf << '\n'
<< " -> sqi = " << sqi << '\n';
return 0;
}
Possible output:
---- simd: std::tie(xf, yf) = bs::remquo(xf, yf)
<- xf = (3, -2, -3, 1)
<- yf = (4, -1, -3, 2)
-> rf = (-1, 0, 0, 1)
-> qi = (1, 2, 1, 0)
---- scalar: std::tie(srf, sqi) = bs::remquo(sxf, syf)
<- sxf = 3
<- syf = 4
-> srf = -1
-> sqi = 1