.\" -*- coding: UTF-8 -*- '\" t .\" Copyright (c) 1990, 1991 The Regents of the University of California. .\" All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" the American National Standards Committee X3, on Information .\" Processing Systems. .\" .\" SPDX-License-Identifier: BSD-4-Clause-UC .\" .\" @(#)strtod.3 5.3 (Berkeley) 6/29/91 .\" .\" Modified Sun Aug 21 17:16:22 1994 by Rik Faith (faith@cs.unc.edu) .\" Modified Sat May 04 19:34:31 MET DST 1996 by Michael Haardt .\" (michael@cantor.informatik.rwth-aachen.de) .\" Added strof, strtold, aeb, 2001-06-07 .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH strtod 3 "5 февраля 2023 г." "Linux man\-pages 6.03" .SH ИМЯ strtod, strtof, strtold \- преобразует строку ASCII в число с плавающей точкой .SH LIBRARY Standard C library (\fIlibc\fP, \fI\-lc\fP) .SH СИНТАКСИС .nf \fB#include \fP .PP \fBdouble strtod(const char *restrict \fP\fInptr\fP\fB, char **restrict \fP\fIendptr\fP\fB);\fP \fBfloat strtof(const char *restrict \fP\fInptr\fP\fB, char **restrict \fP\fIendptr\fP\fB);\fP \fBlong double strtold(const char *restrict \fP\fInptr\fP\fB, char **restrict \fP\fIendptr\fP\fB);\fP .fi .PP .RS -4 Требования макроса тестирования свойств для glibc (см. \fBfeature_test_macros\fP(7)): .RE .PP \fBstrtof\fP(), \fBstrtold\fP(): .nf _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L .fi .SH ОПИСАНИЕ Функции \fBstrtod\fP(), \fBstrtof\fP() и \fBstrtold\fP() преобразуют начальную часть строки, на которую указывает \fInptr\fP, в числа типа \fIdouble\fP, \fIfloat\fP, и \fIlong double\fP, соответственно. .PP The expected form of the (initial portion of the) string is optional leading white space as recognized by \fBisspace\fP(3), an optional plus (\[aq]+\[aq]) or minus sign (\[aq]\-\[aq]) and then either (i) a decimal number, or (ii) a hexadecimal number, or (iii) an infinity, or (iv) a NAN (not\-a\-number). .PP A \fIdecimal number\fP consists of a nonempty sequence of decimal digits possibly containing a radix character (decimal point, locale\-dependent, usually \[aq].\[aq]), optionally followed by a decimal exponent. A decimal exponent consists of an \[aq]E\[aq] or \[aq]e\[aq], followed by an optional plus or minus sign, followed by a nonempty sequence of decimal digits, and indicates multiplication by a power of 10. .PP A \fIhexadecimal number\fP consists of a "0x" or "0X" followed by a nonempty sequence of hexadecimal digits possibly containing a radix character, optionally followed by a binary exponent. A binary exponent consists of a \[aq]P\[aq] or \[aq]p\[aq], followed by an optional plus or minus sign, followed by a nonempty sequence of decimal digits, and indicates multiplication by a power of 2. At least one of radix character and binary exponent must be present. .PP \fIБесконечность\fP — это либо значение «INF» либо «INFINITY», регистр символов не учитывается. .PP Нечисловое значение (\fINAN\fP) — это значение «NAN» (регистр символов не учитывается) возможно сопровождаемое \fI(последовательность n символов)\fP, где \fIпоследовательность n символов\fP, определяет тип нечислового значения в зависимости от текущего представления NAN в системе (смотрите ЗАМЕЧАНИЯ). .SH "ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ" Функции возвращают преобразованное значение, если таковое существует. .PP Если \fIendptr\fP не равно NULL, то указатель на символ, следующий за последним обработанным символом, сохраняется в место, указываемое \fIendptr\fP. .PP Если никаких преобразований не производилось, то возвращается ноль, а значение \fInptr\fP сохраняется в той позиции, на которую ссылается \fIendptr\fP (если \fIendptr\fP не равно null). .PP If the correct value would cause overflow, plus or minus \fBHUGE_VAL\fP, \fBHUGE_VALF\fP, or \fBHUGE_VALL\fP is returned (according to the return type and sign of the value), and \fBERANGE\fP is stored in \fIerrno\fP. .PP If the correct value would cause underflow, a value with magnitude no larger than \fBDBL_MIN\fP, \fBFLT_MIN\fP, or \fBLDBL_MIN\fP is returned and \fBERANGE\fP is stored in \fIerrno\fP. .SH ОШИБКИ .TP \fBERANGE\fP Величина оказалась слишком большой или очень маленькой. .SH АТРИБУТЫ Описание терминов данного раздела смотрите в \fBattributes\fP(7). .ad l .nh .TS allbox; lbx lb lb l l l. Интерфейс Атрибут Значение T{ \fBstrtod\fP(), \fBstrtof\fP(), \fBstrtold\fP() T} Безвредность в нитях MT\-Safe locale .TE .hy .ad .sp 1 .SH СТАНДАРТЫ POSIX.1\-2001, POSIX.1\-2008, C99. .SH ЗАМЕЧАНИЯ Так как возвращаемым значением может быть 0 при успешном выполнении и ошибке, вызывающая программа должна присвоить \fIerrno\fP значение 0 до вызова, а после вызова определить возникновение ошибки по ненулевому значению \fIerrno\fP. .PP .\" From glibc 2.8's stdlib/strtod_l.c: .\" We expect it to be a number which is put in the .\" mantissa of the number. .\" It looks as though at least FreeBSD (according to the manual) does .\" something similar. .\" C11 says: "An implementation may use the n-char sequence to determine .\" extra information to be represented in the NaN's significant." В реализации glibc \fIпоследовательность n символов\fP, которая может появляться после «NAN», рассматривается как целое число (с необязательным префиксом «0» или «0x» для указания системы счисления 8 или 16), которое будет помещено в мантиссу возвращаемого значения. .SH ПРИМЕРЫ Пример можно найти в справочной странице \fBstrtol\fP(3); в ней показано использование похожих функций. .SH "СМ. ТАКЖЕ" \fBatof\fP(3), \fBatoi\fP(3), \fBatol\fP(3), \fBnan\fP(3), \fBnanf\fP(3), \fBnanl\fP(3), \fBstrfromd\fP(3), \fBstrtol\fP(3), \fBstrtoul\fP(3) .PP .SH ПЕРЕВОД Русский перевод этой страницы руководства был сделан Alexander Golubev , Azamat Hackimov , Hotellook, Nikita , Spiros Georgaras , Vladislav , Yuri Kozlov и Иван Павлов . .PP Этот перевод является бесплатной документацией; прочитайте .UR https://www.gnu.org/licenses/gpl-3.0.html Стандартную общественную лицензию GNU версии 3 .UE или более позднюю, чтобы узнать об условиях авторского права. Мы не несем НИКАКОЙ ОТВЕТСТВЕННОСТИ. .PP Если вы обнаружите ошибки в переводе этой страницы руководства, пожалуйста, отправьте электронное письмо на .MT man-pages-ru-talks@lists.sourceforge.net .ME .