std:: nan, std:: nanf, std:: nanl
From cppreference.net
|
헤더 파일에 정의됨
<cmath>
|
||
|
float
nanf
(
const
char
*
arg
)
;
|
(1) | (C++11 이후) |
|
double
nan
(
const
char
*
arg
)
;
|
(2) | (C++11 이후) |
|
long
double
nanl
(
const
char
*
arg
)
;
|
(3) | (C++11 이후) |
문자열 arg 를 해당하는 quiet NaN 값으로 변환합니다. 이는 마치 각각 std::strtof , std::strtod , 또는 std::strtold 를 호출하는 것과 같습니다.
1)
호출
std
::
nanf
(
"
n-char-sequence
")
는
n-char-sequence
가 숫자, ASCII 문자, 밑줄의 시퀀스일 때, 다음 호출과 동등합니다
std::
strtof
(
"NAN(
n-char-sequence
)
"
,
(
char
**
)
nullptr
)
;
.
호출
std
::
nanf
(
"
string
")
는, 여기서
string
이
n-char-sequence
도 아니고 빈 문자열도 아닌 경우, 호출
std::
strtof
(
"NAN"
,
(
char
**
)
nullptr
)
;
와 동등합니다.
목차 |
매개변수
| arg | - | NaN의 내용을 식별하는 좁은 문자 문자열 |
반환값
식별 문자열 arg 에 해당하는 정적 NaN 값 또는 구현이 정적 NaN을 지원하지 않는 경우 0.
구현이 IEEE 부동 소수점 연산(IEC 60559)을 지원하는 경우, 조용한 NaN도 지원합니다.
오류 처리
이 함수는 math_errhandling 에 명시된 어떠한 오류 조건에도 적용되지 않습니다.
예제
이 코드 실행
#include <cmath> #include <cstdint> #include <cstring> #include <iostream> int main() { double f1 = std::nan("1"); std::uint64_t f1n; std::memcpy(&f1n, &f1, sizeof f1); std::cout << "nan(\"1\") = " << f1 << " (" << std::hex << f1n << ")\n"; double f2 = std::nan("2"); std::uint64_t f2n; std::memcpy(&f2n, &f2, sizeof f2); std::cout << "nan(\"2\") = " << f2 << " (" << std::hex << f2n << ")\n"; }
가능한 출력:
nan("1") = nan (7ff0000000000001)
nan("2") = nan (7ff0000000000002)
참고 항목
|
(C++11)
|
주어진 숫자가 NaN인지 검사합니다
(함수) |
|
(C++11)
|
float
타입의 quiet NaN으로 평가됩니다
(매크로 상수) |
|
[static]
|
특수 값 "quiet not-a-number"(NaN)을 표현할 수 있는 부동소수점 타입을 식별합니다
(
std::numeric_limits<T>
의 public static member constant)
|
|
[static]
|
특수 값 "signaling not-a-number"(NaN)을 표현할 수 있는 부동소수점 타입을 식별합니다
(
std::numeric_limits<T>
의 public static member constant)
|
|
[static]
|
주어진 부동소수점 타입의 quiet NaN 값을 반환합니다
(
std::numeric_limits<T>
의 public static member function)
|
|
[static]
|
주어진 부동소수점 타입의 signaling NaN 값을 반환합니다
(
std::numeric_limits<T>
의 public static member function)
|
|
C documentation
for
nanf
,
nan
,
nanl
|
|