C++ 中的 isnormal()
在本節中,我們將會看到 C++ 中的 isnormal() 函式。此函式位於 cmath 庫中。此函式用於檢查一個數字是否為正常數字。被認為不正常的數字包括零、無窮或 NaN。
此函式採用 float、double 或 long double 值作為引數。如果該數字為正常數字,則返回 1,否則返回 0。
示例
#include<iostream>
#include<cmath>
using namespace std;
int main() {
cout << "isnormal(" << 5.23 << "): " << isnormal(5.23) << endl;
cout << "isnormal(" << 0.00 << "): " << isnormal(0.00) << endl;
cout << "isnormal(" << 2.0/0.0 << "): " << isnormal(2.0/0.0) << endl;
}輸出
isnormal(5.23): 1 isnormal(0): 0 isnormal(inf): 0
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP