Print this page
11620 strtod man page typo equence

Split Close
Expand all
Collapse all
          --- old/usr/src/man/man3c/strtod.3c
          +++ new/usr/src/man/man3c/strtod.3c
↓ open down ↓ 36 lines elided ↑ open up ↑
  37   37  .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  38   38  .\" If applicable, add the following below this CDDL HEADER, with the
  39   39  .\" fields enclosed by brackets "[]" replaced with your own identifying
  40   40  .\" information: Portions Copyright [yyyy] [name of copyright owner]
  41   41  .\"
  42   42  .\"
  43   43  .\" Copyright 1989 AT&T
  44   44  .\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
  45   45  .\" Portions Copyright (c) 2006, Sun Microsystems, Inc.  All Rights Reserved.
  46   46  .\"
  47      -.TH STRTOD 3C "Nov 1, 2003"
       47 +.TH STRTOD 3C "Aug 25, 2019"
  48   48  .SH NAME
  49   49  strtod, strtof, strtold, atof \- convert string to floating-point number
  50   50  .SH SYNOPSIS
  51      -.LP
  52   51  .nf
  53   52  #include <stdlib.h>
  54   53  
  55   54  \fBdouble\fR \fBstrtod\fR(\fBconst char *restrict\fR \fInptr\fR, \fBchar **restrict\fR \fIendptr\fR);
  56   55  .fi
  57   56  
  58   57  .LP
  59   58  .nf
  60   59  \fBfloat\fR \fBstrtof\fR(\fBconst char *restrict\fR \fInptr\fR, \fBchar **restrict\fR \fIendptr\fR);
  61   60  .fi
↓ open down ↓ 2 lines elided ↑ open up ↑
  64   63  .nf
  65   64  \fBlong double\fR \fBstrtold\fR(\fBconst char *restrict\fR \fInptr\fR, \fBchar **restrict\fR \fIendptr\fR);
  66   65  .fi
  67   66  
  68   67  .LP
  69   68  .nf
  70   69  \fBdouble\fR \fBatof\fR(\fBconst char *\fR\fIstr\fR);
  71   70  .fi
  72   71  
  73   72  .SH DESCRIPTION
  74      -.sp
  75      -.LP
  76   73  The \fBstrtod()\fR, \fBstrtof()\fR, and \fBstrtold()\fR functions convert the
  77   74  initial portion of the string pointed to by \fInptr\fR to \fBdouble\fR,
  78   75  \fBfloat\fR, and \fBlong double\fR representation, respectively. First they
  79   76  decompose the input string into three parts:
  80   77  .RS +4
  81   78  .TP
  82   79  1.
  83   80  An initial, possibly empty, sequence of white-space characters (as specified
  84   81  by \fBisspace\fR(3C))
  85   82  .RE
↓ open down ↓ 56 lines elided ↑ open up ↑
 142  139  
 143  140  .RE
 144  141  .sp
 145  142  .LP
 146  143  In default mode for \fBstrtod()\fR, only decimal, INF/INFINITY, and
 147  144  NAN/NAN(\fIn-char-sequence\fR) forms are recognized. In C99/SUSv3 mode,
 148  145  hexadecimal strings are also recognized.
 149  146  .sp
 150  147  .LP
 151  148  In default mode for \fBstrtod()\fR, the \fIn-char-sequence\fR in the
 152      -NAN(\fIn-char-equence\fR) form can contain any character except ')' (right
      149 +NAN(\fIn-char-sequence\fR) form can contain any character except ')' (right
 153  150  parenthesis) or '\e0' (null).  In C99/SUSv3 mode, the \fIn-char-sequence\fR can
 154  151  contain only upper and lower case letters, digits, and '_' (underscore).
 155  152  .sp
 156  153  .LP
 157  154  The \fBstrtof()\fR and \fBstrtold()\fR functions always function in
 158  155  C99/SUSv3-conformant mode.
 159  156  .sp
 160  157  .LP
 161  158  The subject sequence is defined as the longest initial subsequence of the input
 162  159  string, starting with the first non-white-space character, that is of the
↓ open down ↓ 32 lines elided ↑ open up ↑
 195  192  pointed to by \fIendptr\fR, provided that \fIendptr\fR is not a null pointer.
 196  193  .sp
 197  194  .LP
 198  195  The \fBstrtod()\fR function does not change the setting of \fBerrno\fR if
 199  196  successful.
 200  197  .sp
 201  198  .LP
 202  199  The \fBatof(\fR\fIstr\fR\fB)\fR function call is equivalent to
 203  200  \fBstrtod(\fR\fInptr\fR\fB, (char **)NULL)\fR.
 204  201  .SH RETURN VALUES
 205      -.sp
 206      -.LP
 207  202  Upon successful completion, these functions return the converted value. If no
 208  203  conversion could be performed, \fB0\fR is returned.
 209  204  .sp
 210  205  .LP
 211  206  If the correct value is outside the range of representable values,
 212  207  \fB\(+-HUGE_VAL\fR, \fB\(+-HUGE_VALF\fR, or \fB\(+-HUGE_VALL\fR is returned
 213  208  (according to the sign of the value), a floating point overflow exception is
 214  209  raised, and \fBerrno\fR is set to \fBERANGE\fR.
 215  210  .sp
 216  211  .LP
 217  212  If the correct value would cause an underflow, the correctly rounded result
 218  213  (which may be normal, subnormal, or zero) is returned, a floating point
 219  214  underflow exception is raised, and \fBerrno\fR is set to \fBERANGE\fR.
 220  215  .SH ERRORS
 221      -.sp
 222      -.LP
 223  216  These functions will fail if:
 224  217  .sp
 225  218  .ne 2
 226  219  .na
 227      -\fB\fBERANGE\fR\fR
      220 +\fBERANGE\fR
 228  221  .ad
 229  222  .RS 10n
 230  223  The value to be returned would cause overflow or underflow
 231  224  .RE
 232  225  
 233  226  .sp
 234  227  .LP
 235  228  These functions may fail if:
 236  229  .sp
 237  230  .ne 2
 238  231  .na
 239      -\fB\fBEINVAL\fR\fR
      232 +\fBEINVAL\fR
 240  233  .ad
 241  234  .RS 10n
 242  235  No conversion could be performed.
 243  236  .RE
 244  237  
 245  238  .SH USAGE
 246      -.sp
 247      -.LP
 248  239  Since 0 is returned on error and is also a valid return on success, an
 249  240  application wishing to check for error situations should set \fBerrno\fR to 0,
 250  241  then call \fBstrtod()\fR, \fBstrtof()\fR, or \fBstrtold()\fR, then check
 251  242  \fBerrno\fR.
 252  243  .sp
 253  244  .LP
 254  245  The changes to \fBstrtod()\fR introduced by the ISO/IEC 9899: 1999 standard can
 255  246  alter the behavior of well-formed applications complying with the ISO/IEC 9899:
 256  247  1990 standard and thus earlier versions of IEEE Std 1003.1-200x. One such
 257  248  example would be:
↓ open down ↓ 52 lines elided ↑ open up ↑
 310  301  It's a float with value 16
 311  302  .fi
 312  303  .in -2
 313  304  
 314  305  .sp
 315  306  .LP
 316  307  The change in behavior is due to the inclusion of floating-point numbers in
 317  308  hexadecimal notation without requiring that either a decimal point or the
 318  309  binary exponent be present.
 319  310  .SH ATTRIBUTES
 320      -.sp
 321      -.LP
 322  311  See \fBattributes\fR(5) for descriptions of the following attributes:
 323  312  .sp
 324  313  
 325  314  .sp
 326  315  .TS
 327  316  box;
 328  317  c | c
 329  318  l | l .
 330  319  ATTRIBUTE TYPE  ATTRIBUTE VALUE
 331  320  _
 332  321  CSI     Enabled
 333  322  _
 334  323  Interface Stability     Standard
 335  324  _
 336  325  MT-Level        MT-Safe with exceptions
 337  326  .TE
 338  327  
 339  328  .SH SEE ALSO
 340      -.sp
 341      -.LP
 342  329  \fBisspace\fR(3C), \fBlocaleconv\fR(3C), \fBscanf\fR(3C), \fBsetlocale\fR(3C),
 343  330  \fBstrtol\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)
 344  331  .SH NOTES
 345      -.sp
 346      -.LP
 347  332  The \fBstrtod()\fR and \fBatof()\fR functions can be used safely in
 348  333  multithreaded applications, as long as \fBsetlocale\fR(3C) is not called to
 349  334  change the locale.
 350  335  .sp
 351  336  .LP
 352  337  The DESCRIPTION and RETURN VALUES sections above are very similar to the
 353  338  wording used by the Single UNIX Specification version 2 (SUSv2) and the 1989 C
 354  339  Standard to describe the behavior of the \fBstrtod()\fR function.  Since some
 355  340  users have reported that they find the description confusing, the following
 356  341  notes might be helpful.
↓ open down ↓ 81 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX