Стандарт языка Си С99 TC (1113411), страница 70
Текст из файла (страница 70)
If the subject sequence begins with a minussign, the sequence is interpreted as negated.294) A wide character sequence INF orINFINITY is interpreted as an infinity, if representable in the return type, else like afloating constant that is too large for the range of the return type. A wide charactersequence NAN or NAN(n-wchar-sequenceopt) is interpreted as a quiet NaN, if supportedin the return type, else like a subject sequence part that does not have the expected form;the meaning of the n-wchar sequences is implementation-defined.295) A pointer to thefinal wide string is stored in the object pointed to by endptr, provided that endptr isnot a null pointer.5If the subject sequence has the hexadecimal form and FLT_RADIX is a power of 2, thevalue resulting from the conversion is correctly rounded.6In other than the "C" locale, additional locale-specific subject sequence forms may beaccepted.7If the subject sequence is empty or does not have the expected form, no conversion isperformed; the value of nptr is stored in the object pointed to by endptr, providedthat endptr is not a null pointer.Recommended practice8If the subject sequence has the hexadecimal form, FLT_RADIX is not a power of 2, andthe result is not exactly representable, the result should be one of the two numbers in theappropriate internal format that are adjacent to the hexadecimal floating source value,with the extra stipulation that the error should have a correct sign for the current roundingdirection.294) It is unspecified whether a minus-signed sequence is converted to a negative number directly or bynegating the value resulting from converting the corresponding unsigned sequence (see F.5); the twomethods may yield different results if rounding is toward positive or negative infinity.
In either case,the functions honor the sign of zero if floating-point arithmetic supports signed zeros.295) An implementation may use the n-wchar sequence to determine extra information to be represented inthe NaN’s significand.§7.24.4.1.1Library373ISO/IEC 9899:TC39Committee Draft — Septermber 7, 2007WG14/N1256If the subject sequence has the decimal form and at most DECIMAL_DIG (defined in<float.h>) significant digits, the result should be correctly rounded.
If the subjectsequence D has the decimal form and more than DECIMAL_DIG significant digits,consider the two bounding, adjacent decimal strings L and U, both havingDECIMAL_DIG significant digits, such that the values of L, D, and U satisfy L ≤ D ≤ U.The result should be one of the (equal or adjacent) values that would be obtained bycorrectly rounding L and U according to the current rounding direction, with the extrastipulation that the error with respect to D should have a correct sign for the currentrounding direction.296)Returns10The functions return the converted value, if any. If no conversion could be performed,zero is returned.
If the correct value is outside the range of representable values, plus orminus HUGE_VAL, HUGE_VALF, or HUGE_VALL is returned (according to the returntype and sign of the value), and the value of the macro ERANGE is stored in errno. Ifthe result underflows (7.12.1), the functions return a value whose magnitude is no greaterthan the smallest normalized positive number in the return type; whether errno acquiresthe value ERANGE is implementation-defined.296) DECIMAL_DIG, defined in <float.h>, should be sufficiently large that L and U will usually roundto the same internal floating value, but if not will round to adjacent values.374Library§7.24.4.1.1WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC37.24.4.1.2 The wcstol, wcstoll, wcstoul, and wcstoull functionsSynopsis1#include <wchar.h>long int wcstol(const wchar_t * restrict nptr,wchar_t ** restrict endptr,int base);long long int wcstoll(const wchar_t * restrict nptr,wchar_t ** restrict endptr,int base);unsigned long int wcstoul(const wchar_t * restrict nptr,wchar_t ** restrict endptr,int base);unsigned long long int wcstoull(const wchar_t * restrict nptr,wchar_t ** restrict endptr,int base);Description2The wcstol, wcstoll, wcstoul, and wcstoull functions convert the initialportion of the wide string pointed to by nptr to long int, long long int,unsigned long int, and unsigned long long int representation,respectively.
First, they decompose the input string into three parts: an initial, possiblyempty, sequence of white-space wide characters (as specified by the iswspacefunction), a subject sequence resembling an integer represented in some radix determinedby the value of base, and a final wide string of one or more unrecognized widecharacters, including the terminating null wide character of the input wide string. Then,they attempt to convert the subject sequence to an integer, and return the result.3If the value of base is zero, the expected form of the subject sequence is that of aninteger constant as described for the corresponding single-byte characters in 6.4.4.1,optionally preceded by a plus or minus sign, but not including an integer suffix.
If thevalue of base is between 2 and 36 (inclusive), the expected form of the subject sequenceis a sequence of letters and digits representing an integer with the radix specified bybase, optionally preceded by a plus or minus sign, but not including an integer suffix.The letters from a (or A) through z (or Z) are ascribed the values 10 through 35; onlyletters and digits whose ascribed values are less than that of base are permitted.
If thevalue of base is 16, the wide characters 0x or 0X may optionally precede the sequenceof letters and digits, following the sign if present.§7.24.4.1.2Library375ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12564The subject sequence is defined as the longest initial subsequence of the input widestring, starting with the first non-white-space wide character, that is of the expected form.The subject sequence contains no wide characters if the input wide string is empty orconsists entirely of white space, or if the first non-white-space wide character is otherthan a sign or a permissible letter or digit.5If the subject sequence has the expected form and the value of base is zero, the sequenceof wide characters starting with the first digit is interpreted as an integer constantaccording to the rules of 6.4.4.1.
If the subject sequence has the expected form and thevalue of base is between 2 and 36, it is used as the base for conversion, ascribing to eachletter its value as given above. If the subject sequence begins with a minus sign, the valueresulting from the conversion is negated (in the return type). A pointer to the final widestring is stored in the object pointed to by endptr, provided that endptr is not a nullpointer.6In other than the "C" locale, additional locale-specific subject sequence forms may beaccepted.7If the subject sequence is empty or does not have the expected form, no conversion isperformed; the value of nptr is stored in the object pointed to by endptr, providedthat endptr is not a null pointer.Returns8The wcstol, wcstoll, wcstoul, and wcstoull functions return the convertedvalue, if any.
If no conversion could be performed, zero is returned. If the correct valueis outside the range of representable values, LONG_MIN, LONG_MAX, LLONG_MIN,LLONG_MAX, ULONG_MAX, or ULLONG_MAX is returned (according to the return typesign of the value, if any), and the value of the macro ERANGE is stored in errno.7.24.4.2 Wide string copying functions7.24.4.2.1 The wcscpy functionSynopsis1#include <wchar.h>wchar_t *wcscpy(wchar_t * restrict s1,const wchar_t * restrict s2);Description2The wcscpy function copies the wide string pointed to by s2 (including the terminatingnull wide character) into the array pointed to by s1.Returns3The wcscpy function returns the value of s1.376Library§7.24.4.2.1WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC37.24.4.2.2 The wcsncpy functionSynopsis1#include <wchar.h>wchar_t *wcsncpy(wchar_t * restrict s1,const wchar_t * restrict s2,size_t n);Description2The wcsncpy function copies not more than n wide characters (those that follow a nullwide character are not copied) from the array pointed to by s2 to the array pointed to bys1.297)3If the array pointed to by s2 is a wide string that is shorter than n wide characters, nullwide characters are appended to the copy in the array pointed to by s1, until n widecharacters in all have been written.Returns4The wcsncpy function returns the value of s1.7.24.4.2.3 The wmemcpy functionSynopsis1#include <wchar.h>wchar_t *wmemcpy(wchar_t * restrict s1,const wchar_t * restrict s2,size_t n);Description2The wmemcpy function copies n wide characters from the object pointed to by s2 to theobject pointed to by s1.Returns3The wmemcpy function returns the value of s1.297) Thus, if there is no null wide character in the first n wide characters of the array pointed to by s2, theresult will not be null-terminated.§7.24.4.2.3Library377ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12567.24.4.2.4 The wmemmove functionSynopsis1#include <wchar.h>wchar_t *wmemmove(wchar_t *s1, const wchar_t *s2,size_t n);Description2The wmemmove function copies n wide characters from the object pointed to by s2 tothe object pointed to by s1.
Copying takes place as if the n wide characters from theobject pointed to by s2 are first copied into a temporary array of n wide characters thatdoes not overlap the objects pointed to by s1 or s2, and then the n wide characters fromthe temporary array are copied into the object pointed to by s1.Returns3The wmemmove function returns the value of s1.7.24.4.3 Wide string concatenation functions7.24.4.3.1 The wcscat functionSynopsis1#include <wchar.h>wchar_t *wcscat(wchar_t * restrict s1,const wchar_t * restrict s2);Description2The wcscat function appends a copy of the wide string pointed to by s2 (including theterminating null wide character) to the end of the wide string pointed to by s1.