WG14/N1336Committee Draft August 11, 2008ISO/IEC9899:201xminimum value for an object oftype long long int-9223372036854775807 //-(263-1)LLONG MINmaximumvalueforanobjectoftypelonglong int+9223372036854775807//263-1LLONG MAXmaximumvalueforanobjectoftypeunsigned longlong int18446744073709551615//264-1ULLONGMAX2If the value of an object of type char is treated as a signed integer when used in anexpression, the value of CHAR MIN shall be the same as that of SCHAR MIN and thevalue of cHAR MAX shall be the same as that of sCHAR MAX. Otherwise, the value ofCHAR MIN shall be O and the value of CHAR MAX shall be the same as that ofUCHAR_ MAx 16) The value UCHAR_ MAX shallequal 2CHAR_BIT _-1.Forward references: representations of types (6.2.6), conditional inclusion (6.10.1).5.2.4.2.2 Characteristics offloating types<f1oat.h>The characteristics of floating types are defined in terms of a model that describes arepresentation of floating-point numbers and values that provide information about animplementation's floating-point arithmetic.17) The following parameters are used todefine themodelfor eachfloating-pointtype:sign (±1)sbbaseorradixofexponentrepresentation(aninteger>1)eexponent(an integerbetweenaminimumeminand amaximum emax)pprecision (the number of base-b digits in the significand)fknonnegative integers less than b (the significand digits)2Afloating-point number (x)is defined by the following model:X=sb"2fib*, emin SeS emxk=13In addition to normalized floating-point numbers (f, > 0 if x + O), floating types may beable to contain other kinds of floating-point numbers, such as subnormal floating-pointnumbers (x ±0, e = emin, fi =0) and unnormalized floating-point numbers (x ± 0,e > emins fi = O), and values that are not floating-point numbers, such as infinities andNaNs. A NaN is an encoding signifying Not-a-Number. A quiet NaN propagatesthrough almost every arithmetic operation without raising a floating-point exception; asignaling NaN generally raises a floating-point exception when occurring as an16)See6.2.5.17)The floating-point model is intended to clarify the description of each floating-point characteristic anddoes notrequirethefloating-point arithmetic of theimplementationtobeidentical23$5.2.4.2.2Environment
WG14/N1336 Committee Draft — August 11, 2008 ISO/IEC 9899:201x — minimum value for an object of type long long int LLONG_MIN -9223372036854775807 // −(263 − 1) — maximum value for an object of type long long int LLONG_MAX +9223372036854775807 // 2 63 − 1 — maximum value for an object of type unsigned long long int ULLONG_MAX 18446744073709551615 // 2 64 − 1 2 If the value of an object of type char is treated as a signed integer when used in an expression, the value of CHAR_MIN shall be the same as that of SCHAR_MIN and the value of CHAR_MAX shall be the same as that of SCHAR_MAX. Otherwise, the value of CHAR_MIN shall be 0 and the value of CHAR_MAX shall be the same as that of UCHAR_MAX. 16) The value UCHAR_MAX shall equal 2CHAR_BIT − 1. Forward references: representations of types (6.2.6), conditional inclusion (6.10.1). 5.2.4.2.2 Characteristics of floating types <float.h> 1 The characteristics of floating types are defined in terms of a model that describes a representation of floating-point numbers and values that provide information about an implementation’s floating-point arithmetic.17) The following parameters are used to define the model for each floating-point type: s sign (±1) b base or radix of exponent representation (an integer > 1) e exponent (an integer between a minimum emin and a maximum emax) p precision (the number of base-b digits in the significand) fk nonnegative integers less than b (the significand digits) 2 A floating-point number (x) is defined by the following model: x = sbe p k=1 Σ fkb −k , emin ≤ e ≤ emax 3 In addition to normalized floating-point numbers ( f1 >0 if x ≠ 0), floating types may be able to contain other kinds of floating-point numbers, such as subnormal floating-point numbers (x ≠ 0, e = emin, f1 = 0) and unnormalized floating-point numbers (x ≠ 0, e > emin, f1 = 0), and values that are not floating-point numbers, such as infinities and NaNs. A NaN is an encoding signifying Not-a-Number. A quiet NaN propagates through almost every arithmetic operation without raising a floating-point exception; a signaling NaN generally raises a floating-point exception when occurring as an 16) See 6.2.5. 17) The floating-point model is intended to clarify the description of each floating-point characteristic and does not require the floating-point arithmetic of the implementation to be identical. §5.2.4.2.2 Environment 23
ISO/IEC9899:201xCommittee Draft August 11, 2008WG14/N1336arithmetic operand.18)4An implementation may give zero and non-numeric values (such as infinities and NaNs)asign or may leave them unsigned. Wherever such values are unsigned, any requirementin this International Standard to retrieve the sign shall produce an unspecified sign, andany requirement to set the sign shall be ignored.5Theaccuracyof thefloating-pointoperations(+,-,*,/)andofthelibraryfunctions in<math.h> and<complex.h> that return floating-point results is implementation-defined, as is the accuracy of the conversion between floating-point internalrepresentations and string representations performed by the library functions in<stdio.h>,<stdlib.h>, and<wchar.h>.The implementation may state that theaccuracy is unknown.6All integer values in the <float.h> header, except FLT ROUNDS, shall be constantexpressions suitable for use in #if preprocessing directives; all floating values shall beconstantexpressions.All exceptDECIMAL_DIG,FLT EVAL METHOD,FLT_RADIX,and FLT_ROUNDs have separate names for all three floating-point types. The floating-pointmodel representation is provided forallvalues exceptFLT_EVAL_METHOD andFLT ROUNDS.7The rounding mode for floating-point addition is characterized by the implementation-definedvalue of FLT_ROUNDS:19)-1indeterminable0toward zero1to nearest2toward positive infinity3towardnegativeinfinityAll other values for FLT ROUNDs characterize implementation-defined roundingbehavior.8Exceptfor assignment and cast (which remove all extra range and precision),thevaluesof operations with floating operands and values subject to the usual arithmeticconversions and offoating constants areevaluated toaformatwhoserange and precisionmay be greater than required by the type.The use of evaluation formats is characterizedby the implementation-defined value of FLT_EVAL_METHOD:20)18)IEC60559:1989 specifies quiet and signaling NaNs.For implementations that do not supportIEC60559:1989, the terms quiet NaN and signaling NaN are intended to apply to encodings withsimilar behavior.19) Evaluation of FLT_ROUNDS correctly reflects any execution-time change of rounding mode throughthefunctionfesetround in<fenv.h>24$5.2.4.2.2Environment
ISO/IEC 9899:201x Committee Draft — August 11, 2008 WG14/N1336 arithmetic operand.18) 4 An implementation may give zero and non-numeric values (such as infinities and NaNs) a sign or may leave them unsigned. Wherever such values are unsigned, any requirement in this International Standard to retrieve the sign shall produce an unspecified sign, and any requirement to set the sign shall be ignored. 5 The accuracy of the floating-point operations (+, -, *, /) and of the library functions in <math.h> and <complex.h> that return floating-point results is implementationdefined, as is the accuracy of the conversion between floating-point internal representations and string representations performed by the library functions in <stdio.h>, <stdlib.h>, and <wchar.h>. The implementation may state that the accuracy is unknown. 6 All integer values in the <float.h> header, except FLT_ROUNDS, shall be constant expressions suitable for use in #if preprocessing directives; all floating values shall be constant expressions. All except DECIMAL_DIG, FLT_EVAL_METHOD, FLT_RADIX, and FLT_ROUNDS have separate names for all three floating-point types. The floatingpoint model representation is provided for all values except FLT_EVAL_METHOD and FLT_ROUNDS. 7 The rounding mode for floating-point addition is characterized by the implementationdefined value of FLT_ROUNDS: 19) -1 indeterminable 0 toward zero 1 to nearest 2 toward positive infinity 3 toward negative infinity All other values for FLT_ROUNDS characterize implementation-defined rounding behavior. 8 Except for assignment and cast (which remove all extra range and precision), the values of operations with floating operands and values subject to the usual arithmetic conversions and of floating constants are evaluated to a format whose range and precision may be greater than required by the type. The use of evaluation formats is characterized by the implementation-defined value of FLT_EVAL_METHOD: 20) 18) IEC 60559:1989 specifies quiet and signaling NaNs. For implementations that do not support IEC 60559:1989, the terms quiet NaN and signaling NaN are intended to apply to encodings with similar behavior. 19) Evaluation of FLT_ROUNDS correctly reflects any execution-time change of rounding mode through the function fesetround in <fenv.h>. 24 Environment §5.2.4.2.2
WG14/N1336Committee Draft — August 11, 2008ISO/IEC9899:201x-1indeterminable;0evaluatealloperationsandconstantsjusttotherangeandprecisionofthetype,1evaluate operations and constants of type float and double to therange and precision of the double type, evaluate longdoubleoperations and constants to therange and precision of thelong doubletype,2evaluate all operations and constants to the range and precision of thelongdoubletype.All other negative values for FLT EVAL METHOD characterize implementation-definedbehavior9The values given in the following list shall be replaced by constant expressions withimplementation-defined values that are greater or equal in magnitude (absolute value) tothose shown, with the same sign:-radixofexponentrepresentation,b2FLT RADIXnumber of base-FLTRADIx digits in thefloating-point significand,pFLT MANT DIGDBL MANT DIGLDBL MANT DIGnumber of decimal digits, n, such that any floating-point number in the widestsupported floating type with Pmax radix b digits can be rounded to a floating-pointnumber with n decimal digits and back again without change to the value,if b is a power of 10Pmax logio b[1+ Pmax logiob] otherwise10DECIMAL DIGnumber of decimal digits,g, such that any floating-point number with g decimal digitscan be rounded into a floating-point number with p radix b digits and back againwithoutchangeto the q decimal digits,20)Theevaluation method determines evaluation formats of expressions involving all floatingtypes,notjust real types.For example,ifFLT EVAL_METHODis I,then theproduct of twofloatComplex operands is represented in the double_Complex format, and its parts are evaluated todouble.25$5.2.4.2.2Environment
WG14/N1336 Committee Draft — August 11, 2008 ISO/IEC 9899:201x -1 indeterminable; 0 evaluate all operations and constants just to the range and precision of the type; 1 evaluate operations and constants of type float and double to the range and precision of the double type, evaluate long double operations and constants to the range and precision of the long double type; 2 evaluate all operations and constants to the range and precision of the long double type. All other negative values for FLT_EVAL_METHOD characterize implementation-defined behavior. 9 The values given in the following list shall be replaced by constant expressions with implementation-defined values that are greater or equal in magnitude (absolute value) to those shown, with the same sign: — radix of exponent representation, b FLT_RADIX 2 — number of base-FLT_RADIX digits in the floating-point significand, p FLT_MANT_DIG DBL_MANT_DIG LDBL_MANT_DIG — number of decimal digits, n, such that any floating-point number in the widest supported floating type with pmax radix b digits can be rounded to a floating-point number with n decimal digits and back again without change to the value, pmax log10 b 1 + pmax log10 b if b is a power of 10 otherwise DECIMAL_DIG 10 — number of decimal digits, q, such that any floating-point number with q decimal digits can be rounded into a floating-point number with p radix b digits and back again without change to the q decimal digits, 20) The evaluation method determines evaluation formats of expressions involving all floating types, not just real types. For example, if FLT_EVAL_METHOD is 1, then the product of two float _Complex operands is represented in the double _Complex format, and its parts are evaluated to double. §5.2.4.2.2 Environment 25
ISO/IEC9899:201xCommittee Draft — August 11, 2008WG14/N1336plogiobif b is a power of 10L(p-1)logiob] otherwise6FLT DIG10DBLDIGLDBL DIG10minimum negative integer such that FLT_RADIX raised to one less than that power isanormalizedfloating-pointnumber, eminFLT MIN EXPDBL MIN EXELDBL MIN EXPminimum negative integer such that 10 raised to that power is in the range ofnormalized floating-point numbers, logio bemi-!FLT MIN 10 EXP3737DBLMIN10_EXP37LDBLMIN10_EXPmaximum integer such that FLT_RADIX raised to one less than that power is arepresentablefinitefloating-point number, emaxFLT MAX EXPDBL MAX EXPLDBL MAX EXPmaximum integer such that 10 raised to that power is in the range of representablefinite floating-point numbers, [logio(1 - b-P)bemax)]+37FLT MAX 10 EXP+37DBL MAX 10 EXPLDBL MAX 10 EXP+3710The values given in the following list shall be replaced by constant expressions withimplementation-defined values that aregreaterthan or equal to those shownmaximum representable finite floating-point number, (1 - b-P)bemaxFLT MAX1E+37DBL MAX1E+37LDBL MAX1E+3711The values given in the following list shall be replaced by constant expressions withimplementation-defined (positive) values that are less than or equal to those shown:-the difference between 1 and the least value greater than 1 that is representable in thegiven floating point type, bl-p26$5.2.4.2.2Environment
ISO/IEC 9899:201x Committee Draft — August 11, 2008 WG14/N1336 p log10 b ( p − 1) log10 b if b is a power of 10 otherwise FLT_DIG 6 DBL_DIG 10 LDBL_DIG 10 — minimum negative integer such that FLT_RADIX raised to one less than that power is a normalized floating-point number, emin FLT_MIN_EXP DBL_MIN_EXP LDBL_MIN_EXP — minimum negative integer such that 10 raised to that power is in the range of normalized floating-point numbers, log10 b emin−1 FLT_MIN_10_EXP -37 DBL_MIN_10_EXP -37 LDBL_MIN_10_EXP -37 — maximum integer such that FLT_RADIX raised to one less than that power is a representable finite floating-point number, emax FLT_MAX_EXP DBL_MAX_EXP LDBL_MAX_EXP — maximum integer such that 10 raised to that power is in the range of representable finite floating-point numbers, log10((1 − b −p )b emax ) FLT_MAX_10_EXP +37 DBL_MAX_10_EXP +37 LDBL_MAX_10_EXP +37 10 The values given in the following list shall be replaced by constant expressions with implementation-defined values that are greater than or equal to those shown: — maximum representable finite floating-point number, (1 − b −p )b emax FLT_MAX 1E+37 DBL_MAX 1E+37 LDBL_MAX 1E+37 11 The values given in the following list shall be replaced by constant expressions with implementation-defined (positive) values that are less than or equal to those shown: — the difference between 1 and the least value greater than 1 that is representable in the given floating point type, b 1−p 26 Environment §5.2.4.2.2
WG14/N1336CommitteeDraftAugust112008ISO/IEC9899:201x1E-5FLT EPSILON1E-9DBL EPSILON1E-9LDBL EPSILONminimum normalized positive floating-point number, bemi-!1E-37FLT_MIN1E-37DBL_MIN1E37LDBL MINRecommended practice12Conversion from (at least)doubleto decimal with DECIMAL DIG digits and backshould be the identity function.EXAMPLE1The following describes an artificial floating-point representation that meets the minimum13requirements of this International Standard, and the appropriate values in a<float.h>header for typefloat:6ZJh16-kx = s16e-31≤e≤+32k=1FLT RADIX166FLT MANT DIGFLT EPSILON9.53674316E-07F6FLT_DIG31FLT MIN EXPFLT_MIN2.93873588E-39FFLT_MIN_10_EXP-38+32FLT MAX EXPFLT MAX3.40282347E+38FFLT MAX_10_EXP+38EXAMPLE22The following describes floating-point representations that also meet the requirements for14single-precision and double-precision normalized numbers in IEC 60559,21)and the appropriate values in a<float.h>headerfor types float and double:2422-Xf = s2e-125≤e≤+128k-153Xa=s2°22*k,-1021≤e≤+1024k=12FLT_RADIX17DECIMAL_DIG24FLT MANT DIG1.19209290E-07F//decimalconstantFLT EPSILONFLT EPSILONOx1P-23F//hexconstant21)The floating-point model in that standard sums powers of b from zero, so the values of the exponentlimitsareonelessthanshownhere.27$5.2.4.2.2Environment
WG14/N1336 Committee Draft — August 11, 2008 ISO/IEC 9899:201x FLT_EPSILON 1E-5 DBL_EPSILON 1E-9 LDBL_EPSILON 1E-9 — minimum normalized positive floating-point number, b emin−1 FLT_MIN 1E-37 DBL_MIN 1E-37 LDBL_MIN 1E-37 Recommended practice 12 Conversion from (at least) double to decimal with DECIMAL_DIG digits and back should be the identity function. 13 EXAMPLE 1 The following describes an artificial floating-point representation that meets the minimum requirements of this International Standard, and the appropriate values in a <float.h> header for type float: x = s16e 6 k=1 Σ fk16−k , −31 ≤ e ≤ +32 FLT_RADIX 16 FLT_MANT_DIG 6 FLT_EPSILON 9.53674316E-07F FLT_DIG 6 FLT_MIN_EXP -31 FLT_MIN 2.93873588E-39F FLT_MIN_10_EXP -38 FLT_MAX_EXP +32 FLT_MAX 3.40282347E+38F FLT_MAX_10_EXP +38 14 EXAMPLE 2 The following describes floating-point representations that also meet the requirements for single-precision and double-precision normalized numbers in IEC 60559,21) and the appropriate values in a <float.h> header for types float and double: x f = s2 e 24 k=1 Σ fk2 −k , −125 ≤ e ≤ +128 xd = s2 e 53 k=1 Σ fk2 −k , −1021 ≤ e ≤ +1024 FLT_RADIX 2 DECIMAL_DIG 17 FLT_MANT_DIG 24 FLT_EPSILON 1.19209290E-07F // decimal constant FLT_EPSILON 0X1P-23F // hex constant 21) The floating-point model in that standard sums powers of b from zero, so the values of the exponent limits are one less than shown here. §5.2.4.2.2 Environment 27