1997-04-02 16:55  Ulrich Drepper  <drepper@cygnus.com>

	* manual/socket.texi: Document behaviour of inet_ntoa in multi-
	threaded programs.
	* manual/stdio.texi: Change wording for snprintf description a bit.
	Correct typo in example.
	* manual/lang.texi: Add documentation of __va_copy.

	* Makefile: Add rule to easily generate dir-add.texi file.
	* manual/Makefile: Likewise.

	* manual/arith.texi: Add description of lldiv_t, lldiv, and atoll.
	Change description of strtoll and strtoull to make clear these
	are the preferred names.
	Describe `inf', `inifinity', `nan', `nan(...)' inputs for strtod
	and friends.
	Change references to HUGE_VALf and HUGE_VALl to HUGE_VALF and
	HUGE_VALL.

	* sysdeps/libm-ieee754/s_nan.c: Use strtod if parameter is not empty
	* sysdeps/libm-ieee754/s_nanl.c: Likewise.
This commit is contained in:
Ulrich Drepper 1997-04-02 22:06:24 +00:00
parent 22d57dd369
commit fe7bdd630f
13 changed files with 162 additions and 3406 deletions

View File

@ -1,3 +1,22 @@
1997-04-02 16:55 Ulrich Drepper <drepper@cygnus.com>
* manual/socket.texi: Document behaviour of inet_ntoa in multi-
threaded programs.
* manual/stdio.texi: Change wording for snprintf description a bit.
Correct typo in example.
* manual/lang.texi: Add documentation of __va_copy.
* Makefile: Add rule to easily generate dir-add.texi file.
* manual/Makefile: Likewise.
* manual/arith.texi: Add description of lldiv_t, lldiv, and atoll.
Change description of strtoll and strtoull to make clear these
are the preferred names.
Describe `inf', `inifinity', `nan', `nan(...)' inputs for strtod
and friends.
Change references to HUGE_VALf and HUGE_VALl to HUGE_VALF and
HUGE_VALL.
1997-04-02 16:28 Ulrich Drepper <drepper@cygnus.com>
* grp/fgetgrent.c: Don't use fixed buffer length. Allow dynamic
@ -31,10 +50,10 @@
* wcsmbs/wcstof.c: Likewise.
* wcsmbs/wcstold.c: Likewise.
* sysdeps/libm-ieee754/s_nan.c: Use strtod is parameter is not empty
* sysdeps/libm-ieee754/s_nan.c: Use strtod if parameter is not empty
string.
* sysdeps/libm-ieee754/s_nanf.c: Likewise.
* sysdeps/libm-ieee754/s_nanld.c: Likewise.
* sysdeps/libm-ieee754/s_nanl.c: Likewise.
1997-04-02 13:56 Ulrich Drepper <drepper@cygnus.com>

View File

@ -313,6 +313,8 @@ makeinfo --no-validate --no-warn --no-headers $< -o $@
endef
INSTALL: manual/maint.texi; $(format-me)
NOTES: manual/creature.texi; $(format-me)
manual/dir-add.texi:
$(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
rpm/%: subdir_distinfo
$(MAKE) $(PARALLELMFLAGS) -C $(@D) subdirs='$(subdirs)' $(@F)

View File

@ -1,540 +0,0 @@
@comment This material was copied from /gd/gnu/doc/lgpl.texinfo.
@node Copying, Concept Index, Maintenance, Top
@appendix GNU GENERAL PUBLIC LICENSE
@center Version 2, June 1991
@display
Copyright @copyright{} 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
@end display
@unnumberedsec Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software---to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
``work based on the library'' and a ``work that uses the library''. The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
@iftex
@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@end iftex
@ifinfo
@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@end ifinfo
@enumerate
@item
This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called ``this License''). Each licensee is
addressed as ``you''.
A ``library'' means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The ``Library'', below, refers to any such software library or work
which has been distributed under these terms. A ``work based on the
Library'' means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term ``modification''.)
``Source code'' for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
@item
You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
@item
You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
@enumerate a
@item
The modified work must itself be a software library.
@item
You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
@item
You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
@item
If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
@end enumerate
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
@item
You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
@item
You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
@item
A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a ``work that uses the Library''. Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a ``work that uses the Library'' with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a ``work that uses the
library''. The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a ``work that uses the Library'' uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
@item
As an exception to the Sections above, you may also compile or
link a ``work that uses the Library'' with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
@enumerate a
@item
Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable ``work that
uses the Library'', as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
@item
Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
@item
If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
@item
Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
@end enumerate
For an executable, the required form of the ``work that uses the
Library'' must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
@item
You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
@enumerate a
@item
Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
@item
Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
@end enumerate
@item
You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
@item
You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
@item
Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
@item
If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
@item
If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
@item
The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
``any later version'', you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
@item
If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
@iftex
@heading NO WARRANTY
@end iftex
@ifinfo
@center NO WARRANTY
@end ifinfo
@item
BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY ``AS IS'' WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
@item
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
@end enumerate
@iftex
@heading END OF TERMS AND CONDITIONS
@end iftex
@ifinfo
@center END OF TERMS AND CONDITIONS
@end ifinfo
@page
@unnumberedsec How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
``copyright'' line and a pointer to where the full notice is found.
@smallexample
@var{one line to give the library's name and a brief idea of what it does.}
Copyright (C) @var{year} @var{name of author}
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@end smallexample
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a ``copyright disclaimer'' for the library, if
necessary. Here is a sample; alter the names:
@example
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
@var{signature of Ty Coon}, 1 April 1990
Ty Coon, President of Vice
@end example
That's all there is to it!

View File

@ -1,414 +0,0 @@
@node Floating-Point Limits
@chapter Floating-Point Limits
@pindex <float.h>
@cindex floating-point number representation
@cindex representation of floating-point numbers
Because floating-point numbers are represented internally as approximate
quantities, algorithms for manipulating floating-point data often need
to be parameterized in terms of the accuracy of the representation.
Some of the functions in the C library itself need this information; for
example, the algorithms for printing and reading floating-point numbers
(@pxref{I/O on Streams}) and for calculating trigonometric and
irrational functions (@pxref{Mathematics}) use information about the
underlying floating-point representation to avoid round-off error and
loss of accuracy. User programs that implement numerical analysis
techniques also often need to be parameterized in this way in order to
minimize or compute error bounds.
The specific representation of floating-point numbers varies from
machine to machine. The GNU C Library defines a set of parameters which
characterize each of the supported floating-point representations on a
particular system.
@menu
* Floating-Point Representation:: Definitions of terminology.
* Floating-Point Parameters:: Descriptions of the library facilities.
* IEEE Floating-Point:: An example of a common representation.
@end menu
@node Floating-Point Representation
@section Floating-Point Representation
This section introduces the terminology used to characterize the
representation of floating-point numbers.
You are probably already familiar with most of these concepts in terms
of scientific or exponential notation for floating-point numbers. For
example, the number @code{123456.0} could be expressed in exponential
notation as @code{1.23456e+05}, a shorthand notation indicating that the
mantissa @code{1.23456} is multiplied by the base @code{10} raised to
power @code{5}.
More formally, the internal representation of a floating-point number
can be characterized in terms of the following parameters:
@itemize @bullet
@item
The @dfn{sign} is either @code{-1} or @code{1}.
@cindex sign (of floating-point number)
@item
The @dfn{base} or @dfn{radix} for exponentiation; an integer greater
than @code{1}. This is a constant for the particular representation.
@cindex base (of floating-point number)
@cindex radix (of floating-point number)
@item
The @dfn{exponent} to which the base is raised. The upper and lower
bounds of the exponent value are constants for the particular
representation.
@cindex exponent (of floating-point number)
Sometimes, in the actual bits representing the floating-point number,
the exponent is @dfn{biased} by adding a constant to it, to make it
always be represented as an unsigned quantity. This is only important
if you have some reason to pick apart the bit fields making up the
floating-point number by hand, which is something for which the GNU
library provides no support. So this is ignored in the discussion that
follows.
@cindex bias, in exponent (of floating-point number)
@item
The value of the @dfn{mantissa} or @dfn{significand}, which is an
unsigned quantity.
@cindex mantissa (of floating-point number)
@cindex significand (of floating-point number)
@item
The @dfn{precision} of the mantissa. If the base of the representation
is @var{b}, then the precision is the number of base-@var{b} digits in
the mantissa. This is a constant for the particular representation.
Many floating-point representations have an implicit @dfn{hidden bit} in
the mantissa. Any such hidden bits are counted in the precision.
Again, the GNU library provides no facilities for dealing with such low-level
aspects of the representation.
@cindex precision (of floating-point number)
@cindex hidden bit, in mantissa (of floating-point number)
@end itemize
The mantissa of a floating-point number actually represents an implicit
fraction whose denominator is the base raised to the power of the
precision. Since the largest representable mantissa is one less than
this denominator, the value of the fraction is always strictly less than
@code{1}. The mathematical value of a floating-point number is then the
product of this fraction; the sign; and the base raised to the exponent.
If the floating-point number is @dfn{normalized}, the mantissa is also
greater than or equal to the base raised to the power of one less
than the precision (unless the number represents a floating-point zero,
in which case the mantissa is zero). The fractional quantity is
therefore greater than or equal to @code{1/@var{b}}, where @var{b} is
the base.
@cindex normalized floating-point number
@node Floating-Point Parameters
@section Floating-Point Parameters
@strong{Incomplete:} This section needs some more concrete examples
of what these parameters mean and how to use them in a program.
These macro definitions can be accessed by including the header file
@file{<float.h>} in your program.
Macro names starting with @samp{FLT_} refer to the @code{float} type,
while names beginning with @samp{DBL_} refer to the @code{double} type
and names beginning with @samp{LDBL_} refer to the @code{long double}
type. (In implementations that do not support @code{long double} as
a distinct data type, the values for those constants are the same
as the corresponding constants for the @code{double} type.)@refill
Note that only @code{FLT_RADIX} is guaranteed to be a constant
expression, so the other macros listed here cannot be reliably used in
places that require constant expressions, such as @samp{#if}
preprocessing directives and array size specifications.
Although the @w{ISO C} standard specifies minimum and maximum values for
most of these parameters, the GNU C implementation uses whatever
floating-point representations are supported by the underlying hardware.
So whether GNU C actually satisfies the @w{ISO C} requirements depends on
what machine it is running on.
@comment float.h
@comment ISO
@defvr Macro FLT_ROUNDS
This value characterizes the rounding mode for floating-point addition.
The following values indicate standard rounding modes:
@table @code
@item -1
The mode is indeterminable.
@item 0
Rounding is towards zero.
@item 1
Rounding is to the nearest number.
@item 2
Rounding is towards positive infinity.
@item 3
Rounding is towards negative infinity.
@end table
@noindent
Any other value represents a machine-dependent nonstandard rounding
mode.
@end defvr
@comment float.h
@comment ISO
@defvr Macro FLT_RADIX
This is the value of the base, or radix, of exponent representation.
This is guaranteed to be a constant expression, unlike the other macros
described in this section.
@end defvr
@comment float.h
@comment ISO
@defvr Macro FLT_MANT_DIG
This is the number of base-@code{FLT_RADIX} digits in the floating-point
mantissa for the @code{float} data type.
@end defvr
@comment float.h
@comment ISO
@defvr Macro DBL_MANT_DIG
This is the number of base-@code{FLT_RADIX} digits in the floating-point
mantissa for the @code{double} data type.
@end defvr
@comment float.h
@comment ISO
@defvr Macro LDBL_MANT_DIG
This is the number of base-@code{FLT_RADIX} digits in the floating-point
mantissa for the @code{long double} data type.
@end defvr
@comment float.h
@comment ISO
@defvr Macro FLT_DIG
This is the number of decimal digits of precision for the @code{float}
data type. Technically, if @var{p} and @var{b} are the precision and
base (respectively) for the representation, then the decimal precision
@var{q} is the maximum number of decimal digits such that any floating
point number with @var{q} base 10 digits can be rounded to a floating
point number with @var{p} base @var{b} digits and back again, without
change to the @var{q} decimal digits.
The value of this macro is guaranteed to be at least @code{6}.
@end defvr
@comment float.h
@comment ISO
@defvr Macro DBL_DIG
This is similar to @code{FLT_DIG}, but is for the @code{double} data
type. The value of this macro is guaranteed to be at least @code{10}.
@end defvr
@comment float.h
@comment ISO
@defvr Macro LDBL_DIG
This is similar to @code{FLT_DIG}, but is for the @code{long double}
data type. The value of this macro is guaranteed to be at least
@code{10}.
@end defvr
@comment float.h
@comment ISO
@defvr Macro FLT_MIN_EXP
This is the minimum negative integer such that the mathematical value
@code{FLT_RADIX} raised to this power minus 1 can be represented as a
normalized floating-point number of type @code{float}. In terms of the
actual implementation, this is just the smallest value that can be
represented in the exponent field of the number.
@end defvr
@comment float.h
@comment ISO
@defvr Macro DBL_MIN_EXP
This is similar to @code{FLT_MIN_EXP}, but is for the @code{double} data
type.
@end defvr
@comment float.h
@comment ISO
@defvr Macro LDBL_MIN_EXP
This is similar to @code{FLT_MIN_EXP}, but is for the @code{long double}
data type.
@end defvr
@comment float.h
@comment ISO
@defvr Macro FLT_MIN_10_EXP
This is the minimum negative integer such that the mathematical value
@code{10} raised to this power minus 1 can be represented as a
normalized floating-point number of type @code{float}. This is
guaranteed to be no greater than @code{-37}.
@end defvr
@comment float.h
@comment ISO
@defvr Macro DBL_MIN_10_EXP
This is similar to @code{FLT_MIN_10_EXP}, but is for the @code{double}
data type.
@end defvr
@comment float.h
@comment ISO
@defvr Macro LDBL_MIN_10_EXP
This is similar to @code{FLT_MIN_10_EXP}, but is for the @code{long
double} data type.
@end defvr
@comment float.h
@comment ISO
@defvr Macro FLT_MAX_EXP
This is the maximum negative integer such that the mathematical value
@code{FLT_RADIX} raised to this power minus 1 can be represented as a
floating-point number of type @code{float}. In terms of the actual
implementation, this is just the largest value that can be represented
in the exponent field of the number.
@end defvr
@comment float.h
@comment ISO
@defvr Macro DBL_MAX_EXP
This is similar to @code{FLT_MAX_EXP}, but is for the @code{double} data
type.
@end defvr
@comment float.h
@comment ISO
@defvr Macro LDBL_MAX_EXP
This is similar to @code{FLT_MAX_EXP}, but is for the @code{long double}
data type.
@end defvr
@comment float.h
@comment ISO
@defvr Macro FLT_MAX_10_EXP
This is the maximum negative integer such that the mathematical value
@code{10} raised to this power minus 1 can be represented as a
normalized floating-point number of type @code{float}. This is
guaranteed to be at least @code{37}.
@end defvr
@comment float.h
@comment ISO
@defvr Macro DBL_MAX_10_EXP
This is similar to @code{FLT_MAX_10_EXP}, but is for the @code{double}
data type.
@end defvr
@comment float.h
@comment ISO
@defvr Macro LDBL_MAX_10_EXP
This is similar to @code{FLT_MAX_10_EXP}, but is for the @code{long
double} data type.
@end defvr
@comment float.h
@comment ISO
@defvr Macro FLT_MAX
The value of this macro is the maximum representable floating-point
number of type @code{float}, and is guaranteed to be at least
@code{1E+37}.
@end defvr
@comment float.h
@comment ISO
@defvr Macro DBL_MAX
The value of this macro is the maximum representable floating-point
number of type @code{double}, and is guaranteed to be at least
@code{1E+37}.
@end defvr
@comment float.h
@comment ISO
@defvr Macro LDBL_MAX
The value of this macro is the maximum representable floating-point
number of type @code{long double}, and is guaranteed to be at least
@code{1E+37}.
@end defvr
@comment float.h
@comment ISO
@defvr Macro FLT_MIN
The value of this macro is the minimum normalized positive
floating-point number that is representable by type @code{float}, and is
guaranteed to be no more than @code{1E-37}.
@end defvr
@comment float.h
@comment ISO
@defvr Macro DBL_MIN
The value of this macro is the minimum normalized positive
floating-point number that is representable by type @code{double}, and
is guaranteed to be no more than @code{1E-37}.
@end defvr
@comment float.h
@comment ISO
@defvr Macro LDBL_MIN
The value of this macro is the minimum normalized positive
floating-point number that is representable by type @code{long double},
and is guaranteed to be no more than @code{1E-37}.
@end defvr
@comment float.h
@comment ISO
@defvr Macro FLT_EPSILON
This is the minimum positive floating-point number of type @code{float}
such that @code{1.0 + FLT_EPSILON != 1.0} is true. It's guaranteed to
be no greater than @code{1E-5}.
@end defvr
@comment float.h
@comment ISO
@defvr Macro DBL_EPSILON
This is similar to @code{FLT_EPSILON}, but is for the @code{double}
type. The maximum value is @code{1E-9}.
@end defvr
@comment float.h
@comment ISO
@defvr Macro LDBL_EPSILON
This is similar to @code{FLT_EPSILON}, but is for the @code{long double}
type. The maximum value is @code{1E-9}.
@end defvr
@node IEEE Floating Point
@section IEEE Floating Point
Here is an example showing how these parameters work for a common
floating point representation, specified by the @cite{IEEE Standard for
Binary Floating-Point Arithmetic (ANSI/IEEE Std 754-1985 or ANSI/IEEE
Std 854-1987)}.
The IEEE single-precision float representation uses a base of 2. There
is a sign bit, a mantissa with 23 bits plus one hidden bit (so the total
precision is 24 base-2 digits), and an 8-bit exponent that can represent
values in the range -125 to 128, inclusive.
So, for an implementation that uses this representation for the
@code{float} data type, appropriate values for the corresponding
parameters are:
@example
FLT_RADIX 2
FLT_MANT_DIG 24
FLT_DIG 6
FLT_MIN_EXP -125
FLT_MIN_10_EXP -37
FLT_MAX_EXP 128
FLT_MAX_10_EXP +38
FLT_MIN 1.17549435E-38F
FLT_MAX 3.40282347E+38F
FLT_EPSILON 1.19209290E-07F
@end example

View File

@ -1,593 +0,0 @@
@node Representation Limits, System Configuration Limits, System Information, Top
@chapter Representation Limits
This chapter contains information about constants and parameters that
characterize the representation of the various integer and
floating-point types supported by the GNU C library.
@menu
* Integer Representation Limits:: Determining maximum and minimum
representation values of
various integer subtypes.
* Floating-Point Limits :: Parameters which characterize
supported floating-point
representations on a particular
system.
@end menu
@node Integer Representation Limits, Floating-Point Limits , , Representation Limits
@section Integer Representation Limits
@cindex integer representation limits
@cindex representation limits, integer
@cindex limits, integer representation
Sometimes it is necessary for programs to know about the internal
representation of various integer subtypes. For example, if you want
your program to be careful not to overflow an @code{int} counter
variable, you need to know what the largest representable value that
fits in an @code{int} is. These kinds of parameters can vary from
compiler to compiler and machine to machine. Another typical use of
this kind of parameter is in conditionalizing data structure definitions
with @samp{#ifdef} to select the most appropriate integer subtype that
can represent the required range of values.
Macros representing the minimum and maximum limits of the integer types
are defined in the header file @file{limits.h}. The values of these
macros are all integer constant expressions.
@pindex limits.h
@comment limits.h
@comment ISO
@deftypevr Macro int CHAR_BIT
This is the number of bits in a @code{char}, usually eight.
@end deftypevr
@comment limits.h
@comment ISO
@deftypevr Macro int SCHAR_MIN
This is the minimum value that can be represented by a @code{signed char}.
@end deftypevr
@comment limits.h
@comment ISO
@deftypevr Macro int SCHAR_MAX
This is the maximum value that can be represented by a @code{signed char}.
@end deftypevr
@comment limits.h
@comment ISO
@deftypevr Macro int UCHAR_MAX
This is the maximum value that can be represented by a @code{unsigned char}.
(The minimum value of an @code{unsigned char} is zero.)
@end deftypevr
@comment limits.h
@comment ISO
@deftypevr Macro int CHAR_MIN
This is the minimum value that can be represented by a @code{char}.
It's equal to @code{SCHAR_MIN} if @code{char} is signed, or zero
otherwise.
@end deftypevr
@comment limits.h
@comment ISO
@deftypevr Macro int CHAR_MAX
This is the maximum value that can be represented by a @code{char}.
It's equal to @code{SCHAR_MAX} if @code{char} is signed, or
@code{UCHAR_MAX} otherwise.
@end deftypevr
@comment limits.h
@comment ISO
@deftypevr Macro int SHRT_MIN
This is the minimum value that can be represented by a @code{signed
short int}. On most machines that the GNU C library runs on,
@code{short} integers are 16-bit quantities.
@end deftypevr
@comment limits.h
@comment ISO
@deftypevr Macro int SHRT_MAX
This is the maximum value that can be represented by a @code{signed
short int}.
@end deftypevr
@comment limits.h
@comment ISO
@deftypevr Macro int USHRT_MAX
This is the maximum value that can be represented by an @code{unsigned
short int}. (The minimum value of an @code{unsigned short int} is zero.)
@end deftypevr
@comment limits.h
@comment ISO
@deftypevr Macro int INT_MIN
This is the minimum value that can be represented by a @code{signed
int}. On most machines that the GNU C system runs on, an @code{int} is
a 32-bit quantity.
@end deftypevr
@comment limits.h
@comment ISO
@deftypevr Macro int INT_MAX
This is the maximum value that can be represented by a @code{signed
int}.
@end deftypevr
@comment limits.h
@comment ISO
@deftypevr Macro {unsigned int} UINT_MAX
This is the maximum value that can be represented by an @code{unsigned
int}. (The minimum value of an @code{unsigned int} is zero.)
@end deftypevr
@comment limits.h
@comment ISO
@deftypevr Macro {long int} LONG_MIN
This is the minimum value that can be represented by a @code{signed long
int}. On most machines that the GNU C system runs on, @code{long}
integers are 32-bit quantities, the same size as @code{int}.
@end deftypevr
@comment limits.h
@comment ISO
@deftypevr Macro {long int} LONG_MAX
This is the maximum value that can be represented by a @code{signed long
int}.
@end deftypevr
@comment limits.h
@comment ISO
@deftypevr Macro {unsigned long int} ULONG_MAX
This is the maximum value that can be represented by an @code{unsigned
long int}. (The minimum value of an @code{unsigned long int} is zero.)
@end deftypevr
@strong{Incomplete:} There should be corresponding limits for the GNU
C Compiler's @code{long long} type, too. (But they are not now present
in the header file.)
The header file @file{limits.h} also defines some additional constants
that parameterize various operating system and file system limits. These
constants are described in @ref{System Parameters} and @ref{File System
Parameters}.
@pindex limits.h
@node Floating-Point Limits , , Integer Representation Limits, Representation Limits
@section Floating-Point Limits
@cindex floating-point number representation
@cindex representation, floating-point number
@cindex limits, floating-point representation
Because floating-point numbers are represented internally as approximate
quantities, algorithms for manipulating floating-point data often need
to be parameterized in terms of the accuracy of the representation.
Some of the functions in the C library itself need this information; for
example, the algorithms for printing and reading floating-point numbers
(@pxref{I/O on Streams}) and for calculating trigonometric and
irrational functions (@pxref{Mathematics}) use information about the
underlying floating-point representation to avoid round-off error and
loss of accuracy. User programs that implement numerical analysis
techniques also often need to be parameterized in this way in order to
minimize or compute error bounds.
The specific representation of floating-point numbers varies from
machine to machine. The GNU C library defines a set of parameters which
characterize each of the supported floating-point representations on a
particular system.
@menu
* Floating-Point Representation:: Definitions of terminology.
* Floating-Point Parameters:: Descriptions of the library
facilities.
* IEEE Floating Point:: An example of a common
representation.
@end menu
@node Floating-Point Representation, Floating-Point Parameters, , Floating-Point Limits
@subsection Floating-Point Representation
This section introduces the terminology used to characterize the
representation of floating-point numbers.
You are probably already familiar with most of these concepts in terms
of scientific or exponential notation for floating-point numbers. For
example, the number @code{123456.0} could be expressed in exponential
notation as @code{1.23456e+05}, a shorthand notation indicating that the
mantissa @code{1.23456} is multiplied by the base @code{10} raised to
power @code{5}.
More formally, the internal representation of a floating-point number
can be characterized in terms of the following parameters:
@itemize @bullet
@item
The @dfn{sign} is either @code{-1} or @code{1}.
@cindex sign (of floating-point number)
@item
The @dfn{base} or @dfn{radix} for exponentiation; an integer greater
than @code{1}. This is a constant for the particular representation.
@cindex base (of floating-point number)
@cindex radix (of floating-point number)
@item
The @dfn{exponent} to which the base is raised. The upper and lower
bounds of the exponent value are constants for the particular
representation.
@cindex exponent (of floating-point number)
Sometimes, in the actual bits representing the floating-point number,
the exponent is @dfn{biased} by adding a constant to it, to make it
always be represented as an unsigned quantity. This is only important
if you have some reason to pick apart the bit fields making up the
floating-point number by hand, which is something for which the GNU
library provides no support. So this is ignored in the discussion that
follows.
@cindex bias (of floating-point number exponent)
@item
The value of the @dfn{mantissa} or @dfn{significand}, which is an
unsigned integer.
@cindex mantissa (of floating-point number)
@cindex significand (of floating-point number)
@item
The @dfn{precision} of the mantissa. If the base of the representation
is @var{b}, then the precision is the number of base-@var{b} digits in
the mantissa. This is a constant for the particular representation.
Many floating-point representations have an implicit @dfn{hidden bit} in
the mantissa. Any such hidden bits are counted in the precision.
Again, the GNU library provides no facilities for dealing with such low-level
aspects of the representation.
@cindex precision (of floating-point number)
@cindex hidden bit (of floating-point number mantissa)
@end itemize
The mantissa of a floating-point number actually represents an implicit
fraction whose denominator is the base raised to the power of the
precision. Since the largest representable mantissa is one less than
this denominator, the value of the fraction is always strictly less than
@code{1}. The mathematical value of a floating-point number is then the
product of this fraction; the sign; and the base raised to the exponent.
If the floating-point number is @dfn{normalized}, the mantissa is also
greater than or equal to the base raised to the power of one less
than the precision (unless the number represents a floating-point zero,
in which case the mantissa is zero). The fractional quantity is
therefore greater than or equal to @code{1/@var{b}}, where @var{b} is
the base.
@cindex normalized floating-point number
@node Floating-Point Parameters, IEEE Floating Point, Floating-Point Representation, Floating-Point Limits
@subsection Floating-Point Parameters
@strong{Incomplete:} This section needs some more concrete examples
of what these parameters mean and how to use them in a program.
These macro definitions can be accessed by including the header file
@file{float.h} in your program.
@pindex float.h
Macro names starting with @samp{FLT_} refer to the @code{float} type,
while names beginning with @samp{DBL_} refer to the @code{double} type
and names beginning with @samp{LDBL_} refer to the @code{long double}
type. (In implementations that do not support @code{long double} as
a distinct data type, the values for those constants are the same
as the corresponding constants for the @code{double} type.)@refill
@cindex @code{float} representation limits
@cindex @code{double} representation limits
@cindex @code{long double} representation limits
Of these macros, only @code{FLT_RADIX} is guaranteed to be a constant
expression. The other macros listed here cannot be reliably used in
places that require constant expressions, such as @samp{#if}
preprocessing directives or array size specifications.
Although the @w{ISO C} standard specifies minimum and maximum values for
most of these parameters, the GNU C implementation uses whatever
floating-point representations are supported by the underlying hardware.
So whether GNU C actually satisfies the @w{ISO C} requirements depends on
what machine it is running on.
@comment float.h
@comment ISO
@deftypevr Macro int FLT_ROUNDS
This value characterizes the rounding mode for floating-point addition.
The following values indicate standard rounding modes:
@table @code
@item -1
The mode is indeterminable.
@item 0
Rounding is towards zero.
@item 1
Rounding is to the nearest number.
@item 2
Rounding is towards positive infinity.
@item 3
Rounding is towards negative infinity.
@end table
@noindent
Any other value represents a machine-dependent nonstandard rounding
mode.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int FLT_RADIX
This is the value of the base, or radix, of exponent representation.
This is guaranteed to be a constant expression, unlike the other macros
described in this section.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int FLT_MANT_DIG
This is the number of base-@code{FLT_RADIX} digits in the floating-point
mantissa for the @code{float} data type.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int DBL_MANT_DIG
This is the number of base-@code{FLT_RADIX} digits in the floating-point
mantissa for the @code{double} data type.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int LDBL_MANT_DIG
This is the number of base-@code{FLT_RADIX} digits in the floating-point
mantissa for the @code{long double} data type.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int FLT_DIG
This is the number of decimal digits of precision for the @code{float}
data type. Technically, if @var{p} and @var{b} are the precision and
base (respectively) for the representation, then the decimal precision
@var{q} is the maximum number of decimal digits such that any floating
point number with @var{q} base 10 digits can be rounded to a floating
point number with @var{p} base @var{b} digits and back again, without
change to the @var{q} decimal digits.
The value of this macro is guaranteed to be at least @code{6}.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int DBL_DIG
This is similar to @code{FLT_DIG}, but is for the @code{double} data
type. The value of this macro is guaranteed to be at least @code{10}.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int LDBL_DIG
This is similar to @code{FLT_DIG}, but is for the @code{long double}
data type. The value of this macro is guaranteed to be at least
@code{10}.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int FLT_MIN_EXP
This is the minimum negative integer such that the mathematical value
@code{FLT_RADIX} raised to this power minus 1 can be represented as a
normalized floating-point number of type @code{float}. In terms of the
actual implementation, this is just the smallest value that can be
represented in the exponent field of the number.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int DBL_MIN_EXP
This is similar to @code{FLT_MIN_EXP}, but is for the @code{double} data
type.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int LDBL_MIN_EXP
This is similar to @code{FLT_MIN_EXP}, but is for the @code{long double}
data type.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int FLT_MIN_10_EXP
This is the minimum negative integer such that the mathematical value
@code{10} raised to this power minus 1 can be represented as a
normalized floating-point number of type @code{float}. This is
guaranteed to be no greater than @code{-37}.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int DBL_MIN_10_EXP
This is similar to @code{FLT_MIN_10_EXP}, but is for the @code{double}
data type.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int LDBL_MIN_10_EXP
This is similar to @code{FLT_MIN_10_EXP}, but is for the @code{long
double} data type.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int FLT_MAX_EXP
This is the maximum negative integer such that the mathematical value
@code{FLT_RADIX} raised to this power minus 1 can be represented as a
floating-point number of type @code{float}. In terms of the actual
implementation, this is just the largest value that can be represented
in the exponent field of the number.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int DBL_MAX_EXP
This is similar to @code{FLT_MAX_EXP}, but is for the @code{double} data
type.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int LDBL_MAX_EXP
This is similar to @code{FLT_MAX_EXP}, but is for the @code{long double}
data type.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int FLT_MAX_10_EXP
This is the maximum negative integer such that the mathematical value
@code{10} raised to this power minus 1 can be represented as a
normalized floating-point number of type @code{float}. This is
guaranteed to be at least @code{37}.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int DBL_MAX_10_EXP
This is similar to @code{FLT_MAX_10_EXP}, but is for the @code{double}
data type.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro int LDBL_MAX_10_EXP
This is similar to @code{FLT_MAX_10_EXP}, but is for the @code{long
double} data type.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro double FLT_MAX
The value of this macro is the maximum representable floating-point
number of type @code{float}, and is guaranteed to be at least
@code{1E+37}.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro double DBL_MAX
The value of this macro is the maximum representable floating-point
number of type @code{double}, and is guaranteed to be at least
@code{1E+37}.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro {long double} LDBL_MAX
The value of this macro is the maximum representable floating-point
number of type @code{long double}, and is guaranteed to be at least
@code{1E+37}.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro double FLT_MIN
The value of this macro is the minimum normalized positive
floating-point number that is representable by type @code{float}, and is
guaranteed to be no more than @code{1E-37}.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro double DBL_MIN
The value of this macro is the minimum normalized positive
floating-point number that is representable by type @code{double}, and
is guaranteed to be no more than @code{1E-37}.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro {long double} LDBL_MIN
The value of this macro is the minimum normalized positive
floating-point number that is representable by type @code{long double},
and is guaranteed to be no more than @code{1E-37}.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro double FLT_EPSILON
This is the minimum positive floating-point number of type @code{float}
such that @code{1.0 + FLT_EPSILON != 1.0} is true. It's guaranteed to
be no greater than @code{1E-5}.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro double DBL_EPSILON
This is similar to @code{FLT_EPSILON}, but is for the @code{double}
type. The maximum value is @code{1E-9}.
@end deftypevr
@comment float.h
@comment ISO
@deftypevr Macro {long double} LDBL_EPSILON
This is similar to @code{FLT_EPSILON}, but is for the @code{long double}
type. The maximum value is @code{1E-9}.
@end deftypevr
@node IEEE Floating Point, , Floating-Point Parameters, Floating-Point Limits
@subsection IEEE Floating Point
@cindex IEEE floating-point representation
@cindex floating-point, IEEE
@cindex IEEE Std 754
Here is an example showing how these parameters work for a common
floating point representation, specified by the @cite{IEEE Standard for
Binary Floating-Point Arithmetic (ANSI/IEEE Std 754-1985 or ANSI/IEEE
Std 854-1987)}. Nearly all computers today use this format.
The IEEE single-precision float representation uses a base of 2. There
is a sign bit, a mantissa with 23 bits plus one hidden bit (so the total
precision is 24 base-2 digits), and an 8-bit exponent that can represent
values in the range -125 to 128, inclusive.
So, for an implementation that uses this representation for the
@code{float} data type, appropriate values for the corresponding
parameters are:
@example
FLT_RADIX 2
FLT_MANT_DIG 24
FLT_DIG 6
FLT_MIN_EXP -125
FLT_MIN_10_EXP -37
FLT_MAX_EXP 128
FLT_MAX_10_EXP +38
FLT_MIN 1.17549435E-38F
FLT_MAX 3.40282347E+38F
FLT_EPSILON 1.19209290E-07F
@end example
Here are the values for the @code{double} data type:
@example
DBL_MANT_DIG 53
DBL_DIG 15
DBL_MIN_EXP -1021
DBL_MIN_10_EXP -307
DBL_MAX_EXP 1024
DBL_MAX_10_EXP 308
DBL_MAX 1.7976931348623157E+308
DBL_MIN 2.2250738585072014E-308
DBL_EPSILON 2.2204460492503131E-016
@end example

File diff suppressed because it is too large Load Diff

View File

@ -1,290 +0,0 @@
@node Variable Argument Facilities, Memory Allocation, Common Definitions, Top
@chapter Variable Argument Facilities
@cindex variadic argument functions
@cindex variadic functions
@cindex variable number of arguments
@cindex optional arguments
@w{ISO C} defines a syntax as part of the kernel language for specifying
functions that take a variable number or type of arguments. (Such
functions are also referred to as @dfn{variadic functions}.) However,
the kernel language provides no mechanism for actually accessing
non-required arguments; instead, you use the variable arguments macros
defined in @file{stdarg.h}.
@pindex stdarg.h
@menu
* Why Variable Arguments are Used:: Using variable arguments can
save you time and effort.
* How Variable Arguments are Used:: An overview of the facilities for
receiving variable arguments.
* Variable Arguments Interface:: Detailed specification of the
library facilities.
* Example of Variable Arguments:: A complete example.
@end menu
@node Why Variable Arguments are Used, How Variable Arguments are Used, , Variable Argument Facilities
@section Why Variable Arguments are Used
Most C functions take a fixed number of arguments. When you define a
function, you also supply a specific data type for each argument.
Every call to the function should supply the same number and type of
arguments as specified in the function definition.
On the other hand, sometimes a function performs an operation that can
meaningfully accept an unlimited number of arguments.
For example, consider a function that joins its arguments into a linked
list. It makes sense to connect any number of arguments together into a
list of arbitrary length. Without facilities for variable arguments,
you would have to define a separate function for each possible number of
arguments you might want to link together. This is an example of a
situation where some kind of mapping or iteration is performed over an
arbitrary number of arguments of the same type.
Another kind of application where variable arguments can be useful is
for functions where values for some arguments can simply be omitted in
some calls, either because they are not used at all or because the
function can determine appropriate defaults for them if they're missing.
The library function @code{printf} (@pxref{Formatted Output}) is an
example of still another class of function where variable arguments are
useful. This function prints its arguments (which can vary in type as
well as number) under the control of a format template string.
@node How Variable Arguments are Used, Variable Arguments Interface, Why Variable Arguments are Used, Variable Argument Facilities
@section How Variable Arguments are Used
This section describes how you can define and call functions that take
variable arguments, and how to access the values of the non-required
arguments.
@menu
* Syntax for Variable Arguments:: How to make a prototype for a
function with variable arguments.
* Receiving the Argument Values:: Steps you must follow to access the
optional argument values.
* How Many Arguments:: How to decide whether there are more
arguments.
* Calling Variadic Functions:: Things you need to know about calling
variable arguments functions.
@end menu
@node Syntax for Variable Arguments, Receiving the Argument Values, , How Variable Arguments are Used
@subsection Syntax for Variable Arguments
A function that accepts a variable number of arguments must have at
least one required argument with a specified type. In the function
definition or prototype declaration, you indicate the fact that a
function can accept additional arguments of unspecified type by putting
@samp{@dots{}} at the end of the arguments. For example,
@example
int
func (const char *a, int b, @dots{})
@{
@dots{}
@}
@end example
@noindent
outlines a definition of a function @code{func} which returns an
@code{int} and takes at least two arguments, the first two being a
@code{const char *} and an @code{int}.@refill
An obscure restriction placed by the @w{ISO C} standard is that the last
required argument must not be declared @code{register} in the function
definition. Furthermore, this argument must not be of a function or
array type, and may not be, for example, a @code{char} or @code{short
int} (whether signed or not) or a @code{float}.
@strong{Compatibility Note:} Many older C dialects provide a similar,
but incompatible, mechanism for defining functions with variable numbers
of arguments. In particular, the @samp{@dots{}} syntax is a new feature
of @w{ISO C}.
@node Receiving the Argument Values, How Many Arguments, Syntax for Variable Arguments, How Variable Arguments are Used
@subsection Receiving the Argument Values
Inside the definition of a variadic function, to access the optional
arguments with the following three step process:
@enumerate
@item
You initialize an argument pointer variable of type @code{va_list} using
@code{va_start}.
@item
You access the optional arguments by successive calls to @code{va_arg}.
@item
You call @code{va_end} to indicate that you are finished accessing the
arguments.
@end enumerate
Steps 1 and 3 must be performed in the function that is defined to
accept variable arguments. However, you can pass the @code{va_list}
variable as an argument to another function and perform all or part of
step 2 there. After doing this, the value of the @code{va_list}
variable in the calling function becomes undefined for further calls to
@code{va_arg}; you should just pass it to @code{va_end}.
You can perform the entire sequence of the three steps multiple times
within a single function invocation. And, if the function doesn't want
to look at its optional arguments at all, it doesn't have to do any of
these steps. It is also perfectly all right for a function to access
fewer arguments than were supplied in the call, but you will get garbage
values if you try to access too many arguments.
@node How Many Arguments, Calling Variadic Functions, Receiving the Argument Values, How Variable Arguments are Used
@subsection How Many Arguments Were Supplied
There is no general way for a function to determine the number and type
of the actual values that were passed as optional arguments. Typically,
the value of one of the required arguments is used to tell the function
this information. It is up to you to define an appropriate calling
convention for each function, and write all calls accordingly.
One calling convention is to make one of the required arguments be an
explicit argument count. This convention is usable if all of the
optional arguments are of the same type.
A required argument can be used as a pattern to specify both the number
and types of the optional arguments. The format template string
argument to @code{printf} is one example of this.
A similar technique that is sometimes used is to have one of the
required arguments be a bit mask, with a bit for each possible optional
argument that might be supplied. The bits are tested in a predefined
sequence; if the bit is set, the value of the next argument is
retrieved, and otherwise a default value is used.
Another technique that is sometimes used is to pass an ``end marker''
value as the last optional argument. For example, for a function that
manipulates an arbitrary number of pointer arguments, a null pointer
might indicate the end of the argument list, provided that a null
pointer isn't otherwise meaningful to the function.
@node Calling Variadic Functions, , How Many Arguments, How Variable Arguments are Used
@subsection Calling Variadic Functions
Functions that are @emph{defined} to be variadic must also be
@emph{declared} to be variadic using a function prototype in the scope
of all calls to it. This is because C compilers might use a different
internal function call protocol for variadic functions than for
functions that take a fixed number and type of arguments. If the
compiler can't determine in advance that the function being called is
variadic, it may end up trying to call it incorrectly and your program
won't work.
@cindex function prototypes
@cindex prototypes for variadic functions
@cindex variadic functions need prototypes
Since the prototype doesn't specify types for optional arguments, in a
call to a variadic function the @dfn{default argument promotions} are
performed on the optional argument values. This means the objects of
type @code{char} or @code{short int} (whether signed or not) are
promoted to either @code{int} or @code{unsigned int}, as appropriate;
and that objects of type @code{float} are promoted to type
@code{double}. So, if the caller passes a @code{char} as an optional
argument, it is promoted to a @code{int}, and the function should get it
with @code{va_arg (@var{ap}, int)}.
Promotions of the required arguments are determined by the function
prototype in the usual way (as if by assignment to the types of the
corresponding formal parameters).
@cindex default argument promotions
@cindex argument promotion
@node Variable Arguments Interface, Example of Variable Arguments, How Variable Arguments are Used, Variable Argument Facilities
@section Variable Arguments Interface
Here are descriptions of the macros used to retrieve variable arguments.
These macros are defined in the header file @file{stdarg.h}.
@pindex stdarg.h
@comment stdarg.h
@comment ISO
@deftp {Data Type} va_list
The type @code{va_list} is used for argument pointer variables.
@end deftp
@comment stdarg.h
@comment ISO
@deftypefn {Macro} void va_start (va_list @var{ap}, @var{last_required})
This macro initialized the argument pointer variable @var{ap} to point
to the first of the optional arguments of the current function;
@var{last_required} must be the last required argument to the function.
@end deftypefn
@comment stdarg.h
@comment ISO
@deftypefn {Macro} @var{type} va_arg (va_list @var{ap}, @var{type})
The @code{va_arg} macro returns the value of the next optional argument,
and changes the internal state of @var{ap} to move past this argument.
Thus, successive uses of @code{va_arg} return successive optional
arguments.
The type of the value returned by @code{va_arg} is the @var{type}
specified in the call.
The @var{type} must match the type of the actual argument, and must not
be @code{char} or @code{short int} or @code{float}. (Remember that the
default argument promotions apply to optional arguments.)
@end deftypefn
@comment stdarg.h
@comment ISO
@deftypefn {Macro} void va_end (va_list @var{ap})
This ends the use of @var{ap}. After a @code{va_end} call, further
@code{va_arg} calls with the same @var{ap} may not work. You should invoke
@code{va_end} before returning from the function in which @code{va_start}
was invoked with the same @var{ap} argument.
In the GNU C library, @code{va_end} does nothing, and you need not ever
use it except for reasons of portability.
@refill
@end deftypefn
@node Example of Variable Arguments, , Variable Arguments Interface, Variable Argument Facilities
@section Example of Variable Arguments
Here is a complete sample function that accepts variable numbers of
arguments. The first argument to the function is the count of remaining
arguments, which are added up and the result returned. (This is
obviously a rather pointless function, but it serves to illustrate the
way the variable arguments facility is commonly used.)
@comment Yes, this example has been tested.
@example
#include <stdarg.h>
int
add_em_up (int count, @dots{})
@{
va_list ap;
int i, sum;
va_start (ap, count); /* @r{Initialize the argument list.} */
sum = 0;
for (i = 0; i < count; i++)
sum = sum + va_arg (ap, int); /* @r{Get the next argument value.} */
va_end (ap); /* @r{Clean up.} */
return sum;
@}
void main (void)
@{
/* @r{This call prints 16.} */
printf ("%d\n", add_em_up (3, 5, 5, 6));
/* @r{This call prints 55.} */
printf ("%d\n", add_em_up (10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
@}
@end example

View File

@ -1,81 +0,0 @@
@node Common Definitions, Memory Allocation, Error Reporting, Top
@chapter Common Definitions
There are some miscellaneous data types and macros that are not part of
the C language kernel but are nonetheless almost universally used, such
as the macro @code{NULL}. In order to use these type and macro
definitions, your program should include the header file
@file{stddef.h}.
@pindex stddef.h
@comment stddef.h
@comment ISO
@deftp {Data Type} ptrdiff_t
This is the signed integer type of the result of subtracting two
pointers. For example, with the declaration @code{char *p1, *p2;}, the
expression @code{p2 - p1} is of type @code{ptrdiff_t}. This will
probably be one of the standard signed integer types (@code{short int},
@code{int} or @code{long int}), but might be a nonstandard type that
exists only for this purpose.
@end deftp
@comment stddef.h
@comment ISO
@deftp {Data Type} size_t
This is an unsigned integer type used to represent the sizes of objects.
The result of the @code{sizeof} operator is of this type, and functions
such as @code{malloc} (@pxref{Unconstrained Allocation}) and
@code{memcpy} (@pxref{Copying and Concatenation}) that manipulate
objects of arbitrary sizes accept arguments of this type to specify
object sizes.
@end deftp
In the GNU system @code{size_t} is equivalent to one of the types
@code{unsigned int} and @code{unsigned long int}. These types have
identical properties on the GNU system, and for most purposes, you
can use them interchangeably. However, they are distinct types,
and in certain contexts, you may not treat them as identical. For
example, when you specify the type of a function argument in a
function prototype, it makes a difference which one you use. If
the system header files declare @code{malloc} with an argument
of type @code{size_t} and you declare @code{malloc} with an argument
of type @code{unsigned int}, you will get a compilation error if
@code{size_t} happens to be @code{unsigned long int} on your system.
To avoid any possibility of error, when a function argument is
supposed to have type @code{size_t}, always write the type as
@code{size_t}, and make no assumptions about what that type might
actually be.
@strong{Compatibility Note:} Types such as @code{size_t} are new
features of @w{ISO C}. Older, pre-ANSI C implementations have
traditionally used @code{unsigned int} for representing object sizes
and @code{int} for pointer subtraction results.
@comment stddef.h
@comment ISO
@deftypevr Macro {void *} NULL
@cindex null pointer
This is a null pointer constant. It can be assigned to any pointer
variable since it has type @code{void *}, and is guaranteed not to
point to any real object. This macro is the best way to get a null
pointer value. You can also use @code{0} or @code{(void *)0} as a null
pointer constant, but using @code{NULL} makes the purpose of the
constant more evident.
When passing a null pointer as an argument to a function for which there
is no prototype declaration in scope, you should explicitly cast
@code{NULL} or @code{0} into a pointer of the appropriate type. Again,
this is because the default argument promotions may not do the right
thing.
@end deftypevr
@comment stddef.h
@comment ISO
@deftypefn {Macro} size_t offsetof (@var{type}, @var{member})
This expands to a integer constant expression that is the offset of the
structure member named @var{member} in a @code{struct} of type
@var{type}. For example, @code{offsetof (struct s, elem)} is the
offset, in bytes, of the member @code{elem} in a @code{struct s}. This
macro won't work if @var{member} is a bit field; you get an error from
the C compiler in that case.
@end deftypefn

View File

@ -66,10 +66,10 @@ stamp-summary: summary.awk $(chapters) $(chapters-incl)
# Generate a file which can be added to the `dir' content to provide direct
# access to the documentation of the function, variables, and other
# definitions.
dir-add.texi: manual/xtract-typefun.awk $(chapters-incl)
if test -n "$(chapters-incl)"; then \
(for i in $(chapters-incl); do \
$(GAWK) -f $< < $i; \
dir-add.texi: xtract-typefun.awk $(chapters)
if test -n "$(chapters)"; then \
(for i in $(chapters); do \
$(GAWK) -f $< < $$i; \
done) | sort > $@.new; \
./move-if-change $@.new $@; \
fi

View File

@ -411,7 +411,36 @@ type @code{long int} rather than @code{int}.)
@deftypefun ldiv_t ldiv (long int @var{numerator}, long int @var{denominator})
The @code{ldiv} function is similar to @code{div}, except that the
arguments are of type @code{long int} and the result is returned as a
structure of type @code{ldiv}.
structure of type @code{ldiv_t}.
@end deftypefun
@comment stdlib.h
@comment GNU
@deftp {Data Type} lldiv_t
This is a structure type used to hold the result returned by the @code{lldiv}
function. It has the following members:
@table @code
@item long long int quot
The quotient from the division.
@item long long int rem
The remainder from the division.
@end table
(This is identical to @code{div_t} except that the components are of
type @code{long long int} rather than @code{int}.)
@end deftp
@comment stdlib.h
@comment GNU
@deftypefun lldiv_t lldiv (long long int @var{numerator}, long long int @var{denominator})
The @code{lldiv} function is like the @code{div} function, but the
arguments are of type @code{long long int} and the result is returned as
a structure of type @code{lldiv_t}.
The @code{lldiv} function is a GNU extension but it will eventually be
part of the next ISO C standard.
@end deftypefun
@ -519,42 +548,48 @@ to @code{EINVAL} and returns @code{0ul}.
@end deftypefun
@comment stdlib.h
@comment BSD
@deftypefun {long long int} strtoq (const char *@var{string}, char **@var{tailptr}, int @var{base})
The @code{strtoq} (``string-to-quad-word'') function is like
@code{strtol} except that is deals with extra long numbers and it
returns its value with type @code{long long int}.
@comment GNU
@deftypefun {long long int} strtoll (const char *@var{string}, char **@var{tailptr}, int @var{base})
The @code{strtoll} function is like @code{strtol} except that is deals
with extra long numbers and it returns its value with type @code{long
long int}.
If the string has valid syntax for an integer but the value is not
representable because of overflow, @code{strtoq} returns either
representable because of overflow, @code{strtoll} returns either
@code{LONG_LONG_MAX} or @code{LONG_LONG_MIN} (@pxref{Range of Type}), as
appropriate for the sign of the value. It also sets @code{errno} to
@code{ERANGE} to indicate there was overflow.
@end deftypefun
@comment stdlib.h
@comment GNU
@deftypefun {long long int} strtoll (const char *@var{string}, char **@var{tailptr}, int @var{base})
@code{strtoll} is only an commonly used other name for the @code{strtoq}
function. Everything said for @code{strtoq} applies to @code{strtoll}
as well.
The @code{strtoll} function is a GNU extension but it will eventually be
part of the next ISO C standard.
@end deftypefun
@comment stdlib.h
@comment BSD
@deftypefun {unsigned long long int} strtouq (const char *@var{string}, char **@var{tailptr}, int @var{base})
The @code{strtouq} (``string-to-unsigned-quad-word'') function is like
@code{strtoul} except that is deals with extra long numbers and it
returns its value with type @code{unsigned long long int}. The value
returned in case of overflow is @code{ULONG_LONG_MAX} (@pxref{Range of Type}).
@deftypefun {long long int} strtoq (const char *@var{string}, char **@var{tailptr}, int @var{base})
@code{strtoq} (``string-to-quad-word'') is only an commonly used other
name for the @code{strtoll} function. Everything said for
@code{strtoll} applies to @code{strtoq} as well.
@end deftypefun
@comment stdlib.h
@comment GNU
@deftypefun {unsigned long long int} strtoull (const char *@var{string}, char **@var{tailptr}, int @var{base})
@code{strtoull} is only an commonly used other name for the @code{strtouq}
function. Everything said for @code{strtouq} applies to @code{strtoull}
as well.
The @code{strtoull} function is like @code{strtoul} except that is deals
with extra long numbers and it returns its value with type
@code{unsigned long long int}. The value returned in case of overflow
is @code{ULONG_LONG_MAX} (@pxref{Range of Type}).
The @code{strtoull} function is a GNU extension but it will eventually be
part of the next ISO C standard.
@end deftypefun
@comment stdlib.h
@comment BSD
@deftypefun {unsigned long long int} strtouq (const char *@var{string}, char **@var{tailptr}, int @var{base})
@code{strtouq} (``string-to-unsigned-quad-word'') is only an commonly
used other name for the @code{strtoull} function. Everything said for
@code{strtoull} applies to @code{strtouq} as well.
@end deftypefun
@comment stdlib.h
@ -574,6 +609,16 @@ value rather than @code{long int}. The @code{atoi} function is also
considered obsolete; use @code{strtol} instead.
@end deftypefun
@comment stdlib.h
@comment GNU
@deftypefun {long long int} atoll (const char *@var{string})
This function is similar to @code{atol}, except it returns a @code{long
long int} value rather than @code{long int}.
The @code{atoll} function is a GNU extension but it will eventually be
part of the next ISO C standard.
@end deftypefun
The POSIX locales contain some information about how to format numbers
(@pxref{General Numeric}). This mainly deals with representing numbers
for better readability for humans. The functions present so far in this
@ -688,6 +733,24 @@ the sign of the value. Similarly, if the value is not representable
because of underflow, @code{strtod} returns zero. It also sets @code{errno}
to @code{ERANGE} if there was overflow or underflow.
There are two more special inputs which are recognized by @code{strtod}.
The string @code{"inf"} or @code{"infinity"} (without consideration of
case and optionally preceded by a @code{"+"} or @code{"-"} sign) is
changed to the floating-point value for infinity if the floating-point
format supports this; and to the largest representable value otherwise.
If the input string is @code{"nan"} or
@code{"nan(@var{n-char-sequence})"} the return value of @code{strtod} is
the representation of the NaN (not a number) value (if the
flaoting-point formats supports this. The form with the
@var{n-char-sequence} enables in an implementation specific way to
specify the form of the NaN value. When using the @w{IEEE 754}
floating-point format, the NaN value can have a lot of forms since only
at least one bit in the mantissa must be set. In the GNU C library
implementation of @code{strtod} the @var{n-char-sequence} is interpreted
as a number (as recognized by @code{strtol}, @pxref{Parsing of Integers})
The mantissa of the return value corresponds to this given number.
Since the value zero which is returned in the error case is also a valid
result the user should set the global variable @code{errno} to zero
before calling this function. So one can test for failures after the
@ -707,7 +770,7 @@ precision can require additional computation.
If the string has valid syntax for a floating-point number but the value
is not representable because of overflow, @code{strtof} returns either
positive or negative @code{HUGE_VALf} (@pxref{Mathematics}), depending on
positive or negative @code{HUGE_VALF} (@pxref{Mathematics}), depending on
the sign of the value.
This function is a GNU extension.
@ -725,7 +788,7 @@ of precision are required.
If the string has valid syntax for a floating-point number but the value
is not representable because of overflow, @code{strtold} returns either
positive or negative @code{HUGE_VALl} (@pxref{Mathematics}), depending on
positive or negative @code{HUGE_VALL} (@pxref{Mathematics}), depending on
the sign of the value.
This function is a GNU extension.

View File

@ -462,6 +462,44 @@ use it except for reasons of portability.
@refill
@end deftypefn
Sometimes it is necessary to parse the list of parameters more than once
or one wants to remember a certain position in the parameter list. To
do this one will have to make a copy of the current value of the
argument. But @code{va_list} is an opaque type and it is not guaranteed
that one can simply assign the value of a variable to another one of
type @code{va_list}
@comment stdarg.h
@comment GNU
@deftypefn {Macro} void __va_copy (va_list @var{dest}, va_list @var{src})
The @code{__va_copy} macro allows copying of objects of type
@code{va_list} even if this is no integral type. The argument pointer
in @var{dest} is initialized to point to the same argument as the
pointer in @var{src}.
This macro is a GNU extension but it will hopefully also be available in
the next update of the ISO C standard.
@end deftypefn
If you want to use @code{__va_copy} you should always be prepared that
this macro is not available. On architectures where a simple assignment
is invalid it hopefully is and so one should always write something like
this:
@smallexample
@{
va_list ap, save;
@dots{}
#ifdef __va_copy
__va_copy (save, ap);
#else
save = ap;
#endif
@dots{}
@}
@end smallexample
@node Variadic Example
@subsection Example of a Variadic Function

View File

@ -826,6 +826,10 @@ string in the standard numbers-and-dots notation. The return value is
a pointer into a statically-allocated buffer. Subsequent calls will
overwrite the same buffer, so you should copy the string if you need
to save it.
In multi-threaded programs each thread has an own statically-allocated
buffer. But still subsequent calls of @code{inet_ntoa} in the same
thread will overwrite the result of the last call.
@end deftypefun
@comment arpa/inet.h

View File

@ -1479,11 +1479,11 @@ the @var{size} argument specifies the maximum number of characters to
produce. The trailing null character is counted towards this limit, so
you should allocate at least @var{size} characters for the string @var{s}.
The return value is the number of characters which are generated for the
given input. If this value is greater than @var{size}, not all
characters from the result have been stored in @var{s}. You should
try again with a bigger output string. Here is an example of doing
this:
The return value is the number of characters which would be generated
for the given input. If this value is greater or equal to @var{size},
not all characters from the result have been stored in @var{s}. You
should try again with a bigger output string. Here is an example of
doing this:
@smallexample
@group
@ -1503,7 +1503,7 @@ make_message (char *name, char *value)
name, value);
@end group
@group
if (nchars) >= size)
if (nchars >= size)
@{
/* @r{Reallocate buffer now that we know how much space is needed.} */
buffer = (char *) xrealloc (buffer, nchars + 1);