[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 2

wcstod Subroutine

Purpose

Converts a wide character string to a double-precision number.

Library

Standard C Library (libc.a)

Syntax

#include <stdlib.h>
double wcstod (NptrEndptr)
const wchar_t *Nptr;
wchar_t **Endptr;

Description

The wcstod subroutine converts the initial portion of the wide character string pointed to by the Nptr parameter to a double-precision number. The input wide character string is first broken down into three parts:

  1. An initial, possibly empty, sequence of white-space wide character codes (as specified by the iswspace subroutine)
  2. A subject sequence interpreted as a floating-point constant
  3. A final wide character string of one or more unrecognized wide character codes (including the terminating wide character null)

The subject sequence is then (if possible) converted to a floating-point number and returned as the result of the wcstod subroutine.

The subject sequence is expected to consist of an optional + (plus sign) or - (minus sign), a non-empty sequence of digits (which may contain a radix), and an optional exponent. The exponent consists of e or E, followed by an optional sign, followed by one or more decimal digits. The subject sequence is the longest initial sub-sequence of the input wide character string (starting with the first non-white-space wide character code) that is of the expected form. The subject sequence contains no wide character codes if the input wide character string is empty or consists entirely of white-space wide character codes, or if the first non-white-space wide character code is other than a sign, a digit, or a radix.

If the subject sequence is valid, the sequence of wide character codes starting with the first digit or radix (whichever occurs first) is interpreted as a float or double constant. If the radix is used in place of a period, and if either an exponent or radix does not appear, a radix is assumed to follow the last digit in the wide character string. If the subject sequence begins with a - (minus sign), the conversion value is negated. A pointer to the final wide character string is stored in the object pointed to by the Endptr parameter, unless it specifies a null pointer. The radix is defined by the LC_NUMERIC category. In the C locale, or in a locale where the radix is not defined, the radix defaults to a period.

Parameters

Nptr Contains a pointer to the wide character string to be converted to a double-precision value.
Endptr Contains a pointer to the position in the string specified by the Nptr parameter where a wide character is found that is not a valid character for the purpose of this conversion.

Return Values

The wcstod subroutine returns a converted double-precision value if a valid floating-point constant is found. If no conversion could be performed, a value of 0 is returned. If the converted value is outside the range (either too high or too low), the errno global variable is set to ERANGE. In case of overflow, plus or minus HUGE_VAL is returned. In the case of underflow, a value of 0 is returned. If the subject sequence is empty or does not have the expected form, no conversion is performed. In this case, the value specified by the Nptr parameter is stored in the object pointed to by the Endptr parameter, provided that the Endptr parameter is not a null pointer.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The iswspace subroutine, wcstol subroutine, wcstoul subroutine.

National Language Support Overview for Programming, Subroutines Overview, Understanding Wide Character String Conversion Subroutines in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Contents | Glossary | Home | Search ]