xref: /csrg-svn/lib/libc/stdlib/strtod.3 (revision 61180)
1*61180Sbostic.\" Copyright (c) 1990, 1991, 1993
2*61180Sbostic.\"	The Regents of the University of California.  All rights reserved.
342114Sbostic.\"
450329Sbostic.\" This code is derived from software contributed to Berkeley by
550329Sbostic.\" the American National Standards Committee X3, on Information
650329Sbostic.\" Processing Systems.
750329Sbostic.\"
842114Sbostic.\" %sccs.include.redist.man%
942114Sbostic.\"
10*61180Sbostic.\"     @(#)strtod.3	8.1 (Berkeley) 06/04/93
1142114Sbostic.\"
1248349Scael.Dd
1348349Scael.Dt STRTOD 3
1448349Scael.Os
1548349Scael.Sh NAME
1648349Scael.Nm strtod
1748349Scael.Nd convert
1848349Scael.Tn ASCII
1948349Scaelstring to double
2048349Scael.Sh SYNOPSIS
2148349Scael.Fd #include <stdlib.h>
2248349Scael.Ft double
2348349Scael.Fn strtod "const char *nptr" "char **endptr"
2448349Scael.Sh DESCRIPTION
2542114SbosticThe
2648349Scael.Fn strtod
2742114Sbosticfunction converts the initial portion of the string
2842114Sbosticpointed to by
2948349Scael.Fa nptr
3042114Sbosticto
3148349Scael.Em double
3242114Sbosticrepresentation.
3348349Scael.Pp
3442114SbosticThe expected form of the string is an optional plus (``+'') or minus
3558393Sbosticsign (``\-'') followed by a sequence of digits optionally containing
3642114Sbostica decimal-point character, optionally followed by an exponent.
3742114SbosticAn exponent consists of an ``E'' or ``e'', followed by an optional plus
3842114Sbosticor minus sign, followed by a sequence of digits.
3948349Scael.Pp
4042114SbosticLeading white-space characters in the string (as defined by the
4148349Scael.Xr isspace 3
4242114Sbosticfunction) are skipped.
4348349Scael.Sh RETURN VALUES
4442114SbosticThe
4548349Scael.Fn strtod
4642114Sbosticfunction returns the converted value, if any.
4748349Scael.Pp
4842114SbosticIf
4948349Scael.Fa endptr
5048349Scaelis not
5148349Scael.Dv NULL ,
5248349Scaela pointer to the character after the last character used
5342114Sbosticin the conversion is stored in the location referenced by
5448349Scael.Fa endptr .
5548349Scael.Pp
5642114SbosticIf no conversion is performed, zero is returned and the value of
5748349Scael.Fa nptr
5842114Sbosticis stored in the location referenced by
5948349Scael.Fa endptr .
6048349Scael.Pp
6142114SbosticIf the correct value would cause overflow, plus or minus
6248349Scael.Dv HUGE_VAL
6342114Sbosticis returned (according to the sign of the value), and
6448349Scael.Dv ERANGE
6542114Sbosticis stored in
6648349Scael.Va errno .
6742114SbosticIf the correct value would cause underflow, zero is
6842114Sbosticreturned and
6948349Scael.Dv ERANGE
7042114Sbosticis stored in
7148349Scael.Va errno .
7248349Scael.Sh ERRORS
7348349Scael.Bl -tag -width [ERANGE]
7448349Scael.It Bq Er ERANGE
7542114SbosticOverflow or underflow occurred.
7648349Scael.Sh SEE ALSO
7748349Scael.Xr atof 3 ,
7848349Scael.Xr atoi 3 ,
7948349Scael.Xr atol 3 ,
8048349Scael.Xr strtol 3 ,
8148349Scael.Xr strtoul 3
8248349Scael.Sh STANDARDS
8348349ScaelThe
8448349Scael.Fn strtod
8548349Scaelfunction
8648349Scaelconforms to
8748349Scael.St -ansiC .
8858393Sbostic.Sh AUTHORS
8958393SbosticThe author of this software is David M. Gay.
9058393Sbostic.Pp
9158393SbosticCopyright (c) 1991 by AT&T.
9258393Sbostic.Pp
9358393SbosticPermission to use, copy, modify, and distribute this software for any
9458393Sbosticpurpose without fee is hereby granted, provided that this entire notice
9558393Sbosticis included in all copies of any software which is or includes a copy
9658393Sbosticor modification of this software and in all copies of the supporting
9758393Sbosticdocumentation for such software.
9858393Sbostic.Pp
9958393SbosticTHIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
10058393SbosticWARRANTY.  IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
10158393SbosticREPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
10258393SbosticOF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
10358393Sbostic.Pp
10458393SbosticContact your vendor for a free copy of the source code to
10548349Scael.Fn strtod
10658393Sbosticand accompanying functions.
107