_atodbl, _atodbl_l, _atoldbl, _atoldbl_l, _atoflt, _atoflt_l

문자열을 double(_atodbl), long double(_atoldbl) 또는 float(_atoflt)로 변환합니다.

구문

int _atodbl( _CRT_DOUBLE * value, char * str );
int _atodbl_l ( _CRT_DOUBLE * value, char * str, _locale_t locale );
int _atoldbl( _LDOUBLE * value, char * str );
int _atoldbl_l ( _LDOUBLE * value, char * str, _locale_t locale );
int _atoflt( _CRT_FLOAT * value, const char * str );
int _atoflt_l( _CRT_FLOAT * value, const char * str, _locale_t locale );

매개 변수

value
문자열을 부동 소수점 값으로 변환하여 생성되는 double, long double 또는 float 값입니다. 이러한 값은 구조체에서 래핑됩니다.

str
부동 소수점 값으로 변환하기 위해 구문 분석할 문자열입니다.

locale
사용할 로캘입니다.

반환 값

정상적으로 실행되는 경우 0을 반환합니다. 가능한 오류 코드는 _UNDERFLOW 헤더 파일 <math.h>에 정의된 코드입니다_OVERFLOW.

설명

이러한 함수는 문자열을 부동 소수점 값으로 변환합니다. 이러한 함수와 atof 함수 제품군의 차이점은 이러한 함수가 부동 소수점 코드를 생성하지 않고 하드웨어 예외를 일으키지 않는다는 것입니다. 대신 오류 조건은 오류 코드로 보고됩니다.

문자열에 부동 소수점 값 value 으로 유효한 해석이 없는 경우 0으로 설정되고 반환 값은 0입니다.

접미사가 있는 _l 이러한 함수 버전은 현재 스레드 로캘 대신 전달된 매개 변수를 사용 locale 한다는 점을 제외하고 접미사가 없는 버전과 동일합니다.

기본적으로 이 함수의 전역 상태는 애플리케이션으로 범위가 지정됩니다. 이 동작을 변경하려면 CRT의 전역 상태를 참조하세요.

요구 사항

루틴 필수 헤더
_atodbl, _atoldbl, _atoflt

_atodbl_l, _atoldbl_l, _atoflt_l
<stdlib.h>

예시

// crt_atodbl.c
// Uses _atodbl to convert a string to a double precision
// floating point value.

#include <stdlib.h>
#include <stdio.h>

int main()
{
   char str1[256] = "3.141592654";
   char abc[256] = "abc";
   char oflow[256] = "1.0E+5000";
   _CRT_DOUBLE dblval;
   _CRT_FLOAT fltval;
   int retval;

   retval = _atodbl(&dblval, str1);

   printf("Double value: %lf\n", dblval.x);
   printf("Return value: %d\n\n", retval);

   retval = _atoflt(&fltval, str1);
   printf("Float value: %f\n", fltval.f);
   printf("Return value: %d\n\n", retval);

   // A non-floating point value: returns 0.
   retval = _atoflt(&fltval, abc);
   printf("Float value: %f\n", fltval.f);
   printf("Return value: %d\n\n", retval);

   // Overflow.
   retval = _atoflt(&fltval, oflow);
   printf("Float value: %f\n", fltval.f);
   printf("Return value: %d\n\n", retval);

   return 0;
}
Double value: 3.141593
Return value: 0

Float value: 3.141593
Return value: 0

Float value: 0.000000
Return value: 0

Float value: inf
Return value: 3

참고 항목

데이터 변환
수학 및 부동 소수점 지원
Locale
atof, _atof_l, _wtof, _wtof_l