_atold, _wtold

De RAD Studio
Aller à : navigation, rechercher

Remonter à math.h - Index


Header File

math.h

Category

Conversion Routines, Math Routines

Prototype

long double _atold(const char *s);

long double _wtold(const wchar_t *s);

Description

Converts a string to a long double.

_wtold is the wide-character version. It converts a wide-character string to a long double.

_atof is the floating-point version of _atold.

_atold converts a string pointed to by s to a long double; this functions recognizes:

An optional string of tabs and spaces

An optional sign

A string of digits and an optional decimal point

An optional e or E followed by an optional signed integer

The first unrecognized character ends the conversion. There are no provisions for overflow.

The functions strtod and _strtold are similar to atof and _atold; they provide better error detection, and hence are preferred in some applications.

Return Value

Returns the converted value of the input string.

If there is an overflow, _atold returns plus or minus HUGE_VAL (or _LHUGE_VAL), errno is set to ERANGE (Result out of range), and _matherr (or _matherrl) is not called.

Example

#include <stdlib.h>
#include <math.h>
long double add_inputs(wchar_t* left, wchar_t* right)
{
  /* Transform the input strings into floats */
  long double d_left = _wtold(left);
  long double d_right = _wtold(right);

  /* Add the transformed floats */
  return d_left + d_right;
}

Portability

POSIX Win32 ANSI C ANSI C++

_atold

+

_wtold

+