Главная » Просмотр файлов » Стандарт языка Си С99 TC

Стандарт языка Си С99 TC (1113411), страница 78

Файл №1113411 Стандарт языка Си С99 TC (Стандарт языка Си С99 + TC) 78 страницаСтандарт языка Си С99 TC (1113411) страница 782019-04-24СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 78)

This transformation,which would be desirable if extra code were required tocause the ‘‘invalid’’ floating-point exception forunordered cases, could be performed provided the stateof the FENV_ACCESS pragma is ‘‘off’’.The sense of relational operators shall be maintained. This includes handling unorderedcases as expressed by the source code.2EXAMPLE// calls g and raises ‘‘invalid’’ if a and b are unorderedif (a < b)f();elseg();is not equivalent to// calls f and raises ‘‘invalid’’ if a and b are unorderedif (a >= b)g();elsef();nor to// calls f without raising ‘‘invalid’’ if a and b are unorderedif (isgreaterequal(a,b))g();elsef();nor, unless the state of the FENV_ACCESS pragma is ‘‘off’’, to§F.8.3IEC 60559 floating-point arithmetic453ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256// calls g without raising ‘‘invalid’’ if a and b are unorderedif (isless(a,b))f();elseg();but is equivalent toif (!(a < b))g();elsef();F.8.4 Constant arithmetic1The implementation shall honor floating-point exceptions raised by execution-timeconstant arithmetic wherever the state of the FENV_ACCESS pragma is ‘‘on’’.

(See F.7.4and F.7.5.) An operation on constants that raises no floating-point exception can befolded during translation, except, if the state of the FENV_ACCESS pragma is ‘‘on’’, afurther check is required to assure that changing the rounding direction to downward doesnot alter the sign of the result,319) and implementations that support dynamic roundingprecision modes shall assure further that the result of the operation raises no floatingpoint exception when converted to the semantic type of the operation.F.9 Mathematics <math.h>1This subclause contains specifications of <math.h> facilities that are particularly suitedfor IEC 60559 implementations.2The Standard C macro HUGE_VAL and its float and long double analogs,HUGE_VALF and HUGE_VALL, expand to expressions whose values are positiveinfinities.3Special cases for functions in <math.h> are covered directly or indirectly byIEC 60559.

The functions that IEC 60559 specifies directly are identified in F.3. Theother functions in <math.h> treat infinities, NaNs, signed zeros, subnormals, and(provided the state of the FENV_ACCESS pragma is ‘‘on’’) the floating-point status flagsin a manner consistent with the basic arithmetic operations covered by IEC 60559.4The expression math_errhandling & MATH_ERREXCEPT shall evaluate to anonzero value.5The ‘‘invalid’’ and ‘‘divide-by-zero’’ floating-point exceptions are raised as specified insubsequent subclauses of this annex.6The ‘‘overflow’’ floating-point exception is raised whenever an infinity — or, because ofrounding direction, a maximal-magnitude finite number — is returned in lieu of a value319) 0 − 0 yields −0 instead of +0 just when the rounding direction is downward.454IEC 60559 floating-point arithmetic§F.9WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3whose magnitude is too large.7The ‘‘underflow’’ floating-point exception is raised whenever a result is tiny (essentiallysubnormal or zero) and suffers loss of accuracy.320)8Whether or when library functions raise the ‘‘inexact’’ floating-point exception isunspecified, unless explicitly specified otherwise.9Whether or when library functions raise an undeserved ‘‘underflow’’ floating-pointexception is unspecified.321) Otherwise, as implied by F.7.6, the <math.h> functions donot raise spurious floating-point exceptions (detectable by the user), other than the‘‘inexact’’ floating-point exception.10Whether the functions honor the rounding direction mode is implementation-defined,unless explicitly specified otherwise.11Functions with a NaN argument return a NaN result and raise no floating-point exception,except where stated otherwise.12The specifications in the following subclauses append to the definitions in <math.h>.For families of functions, the specifications apply to all of the functions even though onlythe principal function is shown.

Unless otherwise specified, where the symbol ‘‘±’’occurs in both an argument and the result, the result has the same sign as the argument.Recommended practice13If a function with one or more NaN arguments returns a NaN result, the result should bethe same as one of the NaN arguments (after possible type conversion), except perhapsfor the sign.F.9.1 Trigonometric functionsF.9.1.1 The acos functions1— acos(1) returns +0.— acos(x) returns a NaN and raises the ‘‘invalid’’ floating-point exception for| x | > 1.320) IEC 60559 allows different definitions of underflow. They all result in the same values, but differ onwhen the floating-point exception is raised.321) It is intended that undeserved ‘‘underflow’’ and ‘‘inexact’’ floating-point exceptions are raised only ifavoiding them would be too costly.§F.9.1.1IEC 60559 floating-point arithmetic455ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256F.9.1.2 The asin functions1— asin(±0) returns ±0.— asin(x) returns a NaN and raises the ‘‘invalid’’ floating-point exception for| x | > 1.F.9.1.3 The atan functions1— atan(±0) returns ±0.— atan(±∞) returns ±π /2.F.9.1.4 The atan2 functions1— atan2(±0, −0) returns ±π .322)— atan2(±0, +0) returns ±0.— atan2(±0, x) returns ±π for x < 0.— atan2(±0, x) returns ±0 for x > 0.— atan2(y, ±0) returns −π /2 for y < 0.— atan2(y, ±0) returns π /2 for y > 0.— atan2(±y, −∞) returns ±π for finite y > 0.— atan2(±y, +∞) returns ±0 for finite y > 0.— atan2(±∞, x) returns ±π /2 for finite x.— atan2(±∞, −∞) returns ±3π /4.— atan2(±∞, +∞) returns ±π /4.F.9.1.5 The cos functions1— cos(±0) returns 1.— cos(±∞) returns a NaN and raises the ‘‘invalid’’ floating-point exception.F.9.1.6 The sin functions1— sin(±0) returns ±0.— sin(±∞) returns a NaN and raises the ‘‘invalid’’ floating-point exception.322) atan2(0, 0) does not raise the ‘‘invalid’’ floating-point exception, nor does atan2( y ,the ‘‘divide-by-zero’’ floating-point exception.456IEC 60559 floating-point arithmetic0) raise§F.9.1.6WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3F.9.1.7 The tan functions1— tan(±0) returns ±0.— tan(±∞) returns a NaN and raises the ‘‘invalid’’ floating-point exception.F.9.2 Hyperbolic functionsF.9.2.1 The acosh functions1— acosh(1) returns +0.— acosh(x) returns a NaN and raises the ‘‘invalid’’ floating-point exception for x < 1.— acosh(+∞) returns +∞.F.9.2.2 The asinh functions1— asinh(±0) returns ±0.— asinh(±∞) returns ±∞.F.9.2.3 The atanh functions1— atanh(±0) returns ±0.— atanh(±1) returns ±∞ and raises the ‘‘divide-by-zero’’ floating-point exception.— atanh(x) returns a NaN and raises the ‘‘invalid’’ floating-point exception for| x | > 1.F.9.2.4 The cosh functions1— cosh(±0) returns 1.— cosh(±∞) returns +∞.F.9.2.5 The sinh functions1— sinh(±0) returns ±0.— sinh(±∞) returns ±∞.F.9.2.6 The tanh functions1— tanh(±0) returns ±0.— tanh(±∞) returns ±1.§F.9.2.6IEC 60559 floating-point arithmetic457ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256F.9.3 Exponential and logarithmic functionsF.9.3.1 The exp functions1— exp(±0) returns 1.— exp(−∞) returns +0.— exp(+∞) returns +∞.F.9.3.2 The exp2 functions1— exp2(±0) returns 1.— exp2(−∞) returns +0.— exp2(+∞) returns +∞.F.9.3.3 The expm1 functions1— expm1(±0) returns ±0.— expm1(−∞) returns −1.— expm1(+∞) returns +∞.F.9.3.4 The frexp functions1— frexp(±0, exp) returns ±0, and stores 0 in the object pointed to by exp.— frexp(±∞, exp) returns ±∞, and stores an unspecified value in the objectpointed to by exp.— frexp(NaN, exp) stores an unspecified value in the object pointed to by exp(and returns a NaN).2frexp raises no floating-point exceptions.3On a binary system, the body of the frexp function might be{*exp = (value == 0) ? 0 : (int)(1 + logb(value));return scalbn(value, -(*exp));}F.9.3.5 The ilogb functions1If the correct result is outside the range of the return type, the numeric result isunspecified and the ‘‘invalid’’ floating-point exception is raised.458IEC 60559 floating-point arithmetic§F.9.3.5WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3F.9.3.6 The ldexp functions1On a binary system, ldexp(x, exp) is equivalent to scalbn(x, exp).F.9.3.7 The log functions1— log(±0) returns −∞ and raises the ‘‘divide-by-zero’’ floating-point exception.— log(1) returns +0.— log(x) returns a NaN and raises the ‘‘invalid’’ floating-point exception for x < 0.— log(+∞) returns +∞.F.9.3.8 The log10 functions1— log10(±0) returns −∞ and raises the ‘‘divide-by-zero’’ floating-point exception.— log10(1) returns +0.— log10(x) returns a NaN and raises the ‘‘invalid’’ floating-point exception for x < 0.— log10(+∞) returns +∞.F.9.3.9 The log1p functions1— log1p(±0) returns ±0.— log1p(−1) returns −∞ and raises the ‘‘divide-by-zero’’ floating-point exception.— log1p(x) returns a NaN and raises the ‘‘invalid’’ floating-point exception forx < −1.— log1p(+∞) returns +∞.F.9.3.10 The log2 functions1— log2(±0) returns −∞ and raises the ‘‘divide-by-zero’’ floating-point exception.— log2(1) returns +0.— log2(x) returns a NaN and raises the ‘‘invalid’’ floating-point exception for x < 0.— log2(+∞) returns +∞.F.9.3.11 The logb functions1— logb(±0) returns −∞ and raises the ‘‘divide-by-zero’’ floating-point exception.— logb(±∞) returns +∞.§F.9.3.11IEC 60559 floating-point arithmetic459ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256F.9.3.12 The modf functions1— modf(±x, iptr) returns a result with the same sign as x.— modf(±∞, iptr) returns ±0 and stores ±∞ in the object pointed to by iptr.— modf(NaN, iptr) stores a NaN in the object pointed to by iptr (and returns aNaN).2modf behaves as though implemented by#include <math.h>#include <fenv.h>#pragma STDC FENV_ACCESS ONdouble modf(double value, double *iptr){int save_round = fegetround();fesetround(FE_TOWARDZERO);*iptr = nearbyint(value);fesetround(save_round);return copysign(isinf(value) ? 0.0 :value - (*iptr), value);}F.9.3.13 The scalbn and scalbln functions1— scalbn(±0, n) returns ±0.— scalbn(x, 0) returns x.— scalbn(±∞, n) returns ±∞.F.9.4 Power and absolute value functionsF.9.4.1 The cbrt functions1— cbrt(±0) returns ±0.— cbrt(±∞) returns ±∞.F.9.4.2 The fabs functions1— fabs(±0) returns +0.— fabs(±∞) returns +∞.460IEC 60559 floating-point arithmetic§F.9.4.2WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3F.9.4.3 The hypot functions1— hypot(x, y), hypot(y, x), and hypot(x, −y) are equivalent.— hypot(x, ±0) is equivalent to fabs(x).— hypot(±∞, y) returns +∞, even if y is a NaN.F.9.4.4 The pow functions1— pow(±0, y) returns ±∞ and raises the ‘‘divide-by-zero’’ floating-point exceptionfor y an odd integer < 0.— pow(±0, y) returns +∞ and raises the ‘‘divide-by-zero’’ floating-point exceptionfor y < 0 and not an odd integer.— pow(±0, y) returns ±0 for y an odd integer > 0.— pow(±0, y) returns +0 for y > 0 and not an odd integer.— pow(−1, ±∞) returns 1.— pow(+1, y) returns 1 for any y, even a NaN.— pow(x, ±0) returns 1 for any x, even a NaN.— pow(x, y) returns a NaN and raises the ‘‘invalid’’ floating-point exception forfinite x < 0 and finite non-integer y.— pow(x, −∞) returns +∞ for | x | < 1.— pow(x, −∞) returns +0 for | x | > 1.— pow(x, +∞) returns +0 for | x | < 1.— pow(x, +∞) returns +∞ for | x | > 1.— pow(−∞, y) returns −0 for y an odd integer < 0.— pow(−∞, y) returns +0 for y < 0 and not an odd integer.— pow(−∞, y) returns −∞ for y an odd integer > 0.— pow(−∞, y) returns +∞ for y > 0 and not an odd integer.— pow(+∞, y) returns +0 for y < 0.— pow(+∞, y) returns +∞ for y > 0.§F.9.4.4IEC 60559 floating-point arithmetic461ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256F.9.4.5 The sqrt functions1sqrt is fully specified as a basic arithmetic operation in IEC 60559.F.9.5 Error and gamma functionsF.9.5.1 The erf functions1— erf(±0) returns ±0.— erf(±∞) returns ±1.F.9.5.2 The erfc functions1— erfc(−∞) returns 2.— erfc(+∞) returns +0.F.9.5.3 The lgamma functions1— lgamma(1) returns +0.— lgamma(2) returns +0.— lgamma(x) returns +∞ and raises the ‘‘divide-by-zero’’ floating-point exception forx a negative integer or zero.— lgamma(−∞) returns +∞.— lgamma(+∞) returns +∞.F.9.5.4 The tgamma functions1— tgamma(±0) returns ±∞ and raises the ‘‘divide-by-zero’’ floating-point exception.— tgamma(x) returns a NaN and raises the ‘‘invalid’’ floating-point exception for x anegative integer.— tgamma(−∞) returns a NaN and raises the ‘‘invalid’’ floating-point exception.— tgamma(+∞) returns +∞.F.9.6 Nearest integer functionsF.9.6.1 The ceil functions1— ceil(±0) returns ±0.— ceil(±∞) returns ±∞.2The double version of ceil behaves as though implemented by462IEC 60559 floating-point arithmetic§F.9.6.1WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3#include <math.h>#include <fenv.h>#pragma STDC FENV_ACCESS ONdouble ceil(double x){double result;int save_round = fegetround();fesetround(FE_UPWARD);result = rint(x); // or nearbyint instead of rintfesetround(save_round);return result;}F.9.6.2 The floor functions1— floor(±0) returns ±0.— floor(±∞) returns ±∞.2See the sample implementation for ceil in F.9.6.1.F.9.6.3 The nearbyint functions1The nearbyint functions use IEC 60559 rounding according to the current roundingdirection.

Характеристики

Тип файла
PDF-файл
Размер
3,61 Mb
Тип материала
Высшее учебное заведение

Список файлов книги

Свежие статьи
Популярно сейчас
Зачем заказывать выполнение своего задания, если оно уже было выполнено много много раз? Его можно просто купить или даже скачать бесплатно на СтудИзбе. Найдите нужный учебный материал у нас!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
6392
Авторов
на СтудИзбе
307
Средний доход
с одного платного файла
Обучение Подробнее