Стандарт языка Си С99 TC (1113411), страница 44
Текст из файла (страница 44)
If the rounded value is outside therange of the return type, the numeric result is unspecified and a domain error or rangeerror may occur.∗Returns3The lrint and llrint functions return the rounded integer value.7.12.9.6 The round functionsSynopsis1#include <math.h>double round(double x);float roundf(float x);long double roundl(long double x);Description2The round functions round their argument to the nearest integer value in floating-pointformat, rounding halfway cases away from zero, regardless of the current roundingdirection.Returns3The round functions return the rounded integer value.§7.12.9.6Library233ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12567.12.9.7 The lround and llround functionsSynopsis1#include <math.h>long int lround(double x);long int lroundf(float x);long int lroundl(long double x);long long int llround(double x);long long int llroundf(float x);long long int llroundl(long double x);Description2The lround and llround functions round their argument to the nearest integer value,rounding halfway cases away from zero, regardless of the current rounding direction.
Ifthe rounded value is outside the range of the return type, the numeric result is unspecifiedand a domain error or range error may occur.Returns3The lround and llround functions return the rounded integer value.7.12.9.8 The trunc functionsSynopsis1#include <math.h>double trunc(double x);float truncf(float x);long double truncl(long double x);Description2The trunc functions round their argument to the integer value, in floating format,nearest to but no larger in magnitude than the argument.Returns3The trunc functions return the truncated integer value.234Library§7.12.9.8WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC37.12.10 Remainder functions7.12.10.1 The fmod functionsSynopsis1#include <math.h>double fmod(double x, double y);float fmodf(float x, float y);long double fmodl(long double x, long double y);Description2The fmod functions compute the floating-point remainder of x/y.Returns3The fmod functions return the value x − ny, for some integer n such that, if y is nonzero,the result has the same sign as x and magnitude less than the magnitude of y.
If y is zero,whether a domain error occurs or the fmod functions return zero is implementationdefined.7.12.10.2 The remainder functionsSynopsis1#include <math.h>double remainder(double x, double y);float remainderf(float x, float y);long double remainderl(long double x, long double y);Description2The remainder functions compute the remainder x REM y required by IEC 60559.210)Returns3The remainder functions return x REM y. If y is zero, whether a domain error occursor the functions return zero is implementation defined.210) ‘‘When y ≠ 0, the remainder r = x REM y is defined regardless of the rounding mode by themathematical relation r = x − ny, where n is the integer nearest the exact value of x/y; whenever| n − x/y | = 1/2, then n is even. Thus, the remainder is always exact.
If r = 0, its sign shall be that ofx.’’ This definition is applicable for all implementations.§7.12.10.2Library235ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12567.12.10.3 The remquo functionsSynopsis1#include <math.h>double remquo(double x, double y, int *quo);float remquof(float x, float y, int *quo);long double remquol(long double x, long double y,int *quo);Description2The remquo functions compute the same remainder as the remainder functions.
Inthe object pointed to by quo they store a value whose sign is the sign of x/y and whosemagnitude is congruent modulo 2n to the magnitude of the integral quotient of x/y, wheren is an implementation-defined integer greater than or equal to 3.Returns3The remquo functions return x REM y. If y is zero, the value stored in the objectpointed to by quo is unspecified and whether a domain error occurs or the functionsreturn zero is implementation defined.7.12.11 Manipulation functions7.12.11.1 The copysign functionsSynopsis1#include <math.h>double copysign(double x, double y);float copysignf(float x, float y);long double copysignl(long double x, long double y);Description2The copysign functions produce a value with the magnitude of x and the sign of y.They produce a NaN (with the sign of y) if x is a NaN.
On implementations thatrepresent a signed zero but do not treat negative zero consistently in arithmeticoperations, the copysign functions regard the sign of zero as positive.Returns3The copysign functions return a value with the magnitude of x and the sign of y.236Library§7.12.11.1WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC37.12.11.2 The nan functionsSynopsis1#include <math.h>double nan(const char *tagp);float nanf(const char *tagp);long double nanl(const char *tagp);Description2The call nan("n-char-sequence") is equivalent to strtod("NAN(n-charsequence)",(char**)NULL); the call nan("") is equivalent tostrtod("NAN()", (char**) NULL).
If tagp does not point to an n-charsequence or an empty string, the call is equivalent to strtod("NAN", (char**)NULL). Calls to nanf and nanl are equivalent to the corresponding calls to strtofand strtold.Returns3The nan functions return a quiet NaN, if available, with content indicated through tagp.If the implementation does not support quiet NaNs, the functions return zero.Forward references: the strtod, strtof, and strtold functions (7.20.1.3).7.12.11.3 The nextafter functionsSynopsis1#include <math.h>double nextafter(double x, double y);float nextafterf(float x, float y);long double nextafterl(long double x, long double y);Description2The nextafter functions determine the next representable value, in the type of thefunction, after x in the direction of y, where x and y are first converted to the type of thefunction.211) The nextafter functions return y if x equals y.
A range error may occurif the magnitude of x is the largest finite value representable in the type and the result isinfinite or not representable in the type.Returns3The nextafter functions return the next representable value in the specified formatafter x in the direction of y.211) The argument values are converted to the type of the function, even by a macro implementation of thefunction.§7.12.11.3Library237ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12567.12.11.4 The nexttoward functionsSynopsis1#include <math.h>double nexttoward(double x, long double y);float nexttowardf(float x, long double y);long double nexttowardl(long double x, long double y);Description2The nexttoward functions are equivalent to the nextafter functions except that thesecond parameter has type long double and the functions return y converted to thetype of the function if x equals y.212)7.12.12 Maximum, minimum, and positive difference functions7.12.12.1 The fdim functionsSynopsis1#include <math.h>double fdim(double x, double y);float fdimf(float x, float y);long double fdiml(long double x, long double y);Description2The fdim functions determine the positive difference between their arguments:x − y if x > yif x ≤ y+0A range error may occur.Returns3The fdim functions return the positive difference value.7.12.12.2 The fmax functionsSynopsis1#include <math.h>double fmax(double x, double y);float fmaxf(float x, float y);long double fmaxl(long double x, long double y);212) The result of the nexttoward functions is determined in the type of the function, without loss ofrange or precision in a floating second argument.238Library§7.12.12.2WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3Description2The fmax functions determine the maximum numeric value of their arguments.213)Returns3The fmax functions return the maximum numeric value of their arguments.7.12.12.3 The fmin functionsSynopsis1#include <math.h>double fmin(double x, double y);float fminf(float x, float y);long double fminl(long double x, long double y);Description2The fmin functions determine the minimum numeric value of their arguments.214)Returns3The fmin functions return the minimum numeric value of their arguments.7.12.13 Floating multiply-add7.12.13.1 The fma functionsSynopsis1#include <math.h>double fma(double x, double y, double z);float fmaf(float x, float y, float z);long double fmal(long double x, long double y,long double z);Description2The fma functions compute (x × y) + z, rounded as one ternary operation: they computethe value (as if) to infinite precision and round once to the result format, according to thecurrent rounding mode.