# std::remquo,std::remquof,std::remquol (3) - Linux Manuals

## std::remquo,std::remquof,std::remquol: std::remquo,std::remquof,std::remquol

## NAME

std::remquo,std::remquof,std::remquol - std::remquo,std::remquof,std::remquol

## Synopsis

Defined in header <cmath>

float remquo ( float x, float y, int* quo ); **(1)** *(since C++11)*

float remquof( float x, float y, int* quo );

double remquo ( double x, double y, int* quo ); **(2)** *(since C++11)*

long double remquo ( long double x, long double y, int* quo ); **(3)** *(since C++11)*

long double remquol( long double x, long double y, int* quo );

Promoted remquo ( Arithmetic1 x, Arithmetic2 y, int* quo ); **(4)** *(since C++11)*

1-3) Computes the floating-point remainder of the division operation x/y as the std::remainder() function does. Additionally, the sign and at least the three of the last bits of x/y will be stored in quo, sufficient to determine the octant of the result within a period.

4) A set of overloads or a function template for all combinations of arguments of arithmetic_type not covered by (1-3). If any non-pointer argument has integral_type, it is cast to double. If any other non-pointer argument is long double, then the return type is long double, otherwise it is double.

## Parameters

x, y - floating point values

quo - pointer to an integer value to store the sign and some bits of x/y

## Return value

If successful, returns the floating-point remainder of the division x/y as defined in std::remainder, and stores, in *quo, the sign and at least three of the least significant bits of x/y (formally, stores a value whose sign is the sign of x/y and whose magnitude is congruent modulo 2n

to the magnitude of the integral quotient of x/y, where n is an implementation-defined integer greater than or equal to 3).

If y is zero, the value stored in *quo is unspecified.

If a domain error occurs, an implementation-defined value is returned (NaN where supported)

If a range error occurs due to underflow, the correct result is returned if subnormals are supported.

If y is zero, but the domain error does not occur, zero is returned.

## Error handling

Errors are reported as specified in math_errhandling.

Domain error may occur if y is zero.

If the implementation supports IEEE floating-point arithmetic (IEC 60559),

* The current rounding_mode has no effect.

* FE_INEXACT is never raised

* If x is ±∞ and y is not NaN, NaN is returned and FE_INVALID is raised

* If y is ±0 and x is not NaN, NaN is returned and FE_INVALID is raised

* If either x or y is NaN, NaN is returned

## Notes

POSIX_requires that a domain error occurs if x is infinite or y is zero.

This function is useful when implementing periodic functions with the period exactly representable as a floating-point value: when calculating sin(πx) for a very large x, calling std::sin directly may result in a large error, but if the function argument is first reduced with std::remquo, the low-order bits of the quotient may be used to determine the sign and the octant of the result within the period, while the remainder may be used to calculate the value with high precision.

On some platforms this operation is supported by hardware (and, for example, on Intel CPUs, FPREM1 leaves exactly 3 bits of precision in the quotient when complete).

## Example

// Run this code