Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
Sınıf şablonu, yerleşik sayısal türlerin aritmetik özelliklerini açıklar.
Sözdizimi
template <class Type>
class numeric_limits
Parametreler
Tür
Özellikleri test edilen, sorgulanan veya ayarlanan temel öğe veri türü. Tür, , volatileveya const volatileolarak da bildirilebilirconst.
Açıklamalar
Üst bilgi, , , , , , bool, , long longintlongunsigned longunsigned intfloatunsigned shortdoubleunsigned long longshortchar32_tchar16_tlong doubleve türleri wchar_tiçin açık özelleştirmeler tanımlar. unsigned charsigned charchar Bu açık özelleştirmeler için numeric_limits::is_specialized üyesidir trueve tüm ilgili üyeler anlamlı değerlere sahiptir. Program ek açık özelleştirmeler sağlayabilir. sınıfının çoğu üye işlevi, uygulamasının olası uygulamalarını açıklar veya test eder float.
Rastgele bir özelleştirme için hiçbir üyenin anlamlı değerleri yoktur. Anlamlı değeri olmayan bir üye nesnesi sıfır (veya false) depolar ve anlamlı bir değer döndürmeyen bir üye işlevi döndürür Type(0).
Statik İşlevler ve Sabitler
| Veri Akışı Adı | Açıklama |
|---|---|
| denorm_min | Sıfır olmayan en küçük normalleştirilmiş değeri döndürür. |
| Basamak | Türün duyarlık kaybı olmadan gösterebileceği radix basamaklarının sayısını döndürür. |
| rakamlar10 | Türün duyarlık kaybı olmadan gösterebileceği ondalık basamak sayısını döndürür. |
| Epsilon | Veri türünün gösterebileceği 1 ile 1'den büyük en küçük değer arasındaki farkı döndürür. |
| has_denorm | Bir türün normalleştirilmiş değerlere izin verip vermeyeceğini test eder. |
| has_denorm_loss | Kesinlik kaybının, kesin olmayan bir sonuç olarak değil, normalleştirme kaybı olarak algılanıp algılanamadığnı test eder. |
| has_infinity | Bir türün pozitif sonsuzluk gösterimi olup olmadığını test eder. |
| has_quiet_NaN | Bir türün sinyal olmayan bir sayı (NAN) değil de sessiz bir gösterime sahip olup olmadığını sınar. |
| has_signaling_NaN | Bir türün sayı (NAN) değil sinyal için bir gösterimi olup olmadığını sınar. |
| sonsuzluk | Varsa, bir tür için pozitif sonsuzluk gösterimi. |
| is_bounded | Bir türün gösterebileceği değer kümesinin sınırlı olup olmadığını test eder. |
| is_exact | Bir tür üzerinde yapılan hesaplamalarda yuvarlama hatası olup olmadığını test eder. |
| is_iec559 | Bir türün IEC 559 standartlarına uygun olup olmadığını test eder. |
| is_integer | Bir türün tamsayı gösterimi olup olmadığını sınar. |
| is_modulo | Bir türün modulo gösterimi olup olmadığını sınar. |
| is_signed | Bir türün imzalı gösterimi olup olmadığını sınar. |
| is_specialized | Bir türün sınıf şablonunda numeric_limitstanımlanmış açık bir özelleştirmesi olup olmadığını sınar. |
| En düşük | En negatif sonlu değeri döndürür. |
| Max | Bir tür için en yüksek sonlu değeri döndürür. |
| max_digits10 | Türün iki ayrı değerinin ayrı ondalık gösterimleri olduğundan emin olmak için gereken ondalık basamak sayısını döndürür. |
| max_exponent | Kayan nokta türünün bir radik tabanı bu güce yükseltildiğinde sonlu değer olarak gösterebileceği maksimum pozitif tamsayı üssünü döndürür. |
| max_exponent10 | Kayan nokta türünün, on tabanı bu güce yükseltildiğinde sonlu değer olarak gösterebileceği maksimum pozitif tamsayı üssünü döndürür. |
| min | Bir tür için en düşük normalleştirilmiş değeri döndürür. |
| min_exponent | Bir sayı tabanı bu güce yükseltildiğinde kayan nokta türünün sonlu değer olarak gösterebileceği maksimum negatif tam sayı üssünü döndürür. |
| min_exponent10 | Kayan nokta türünün, on tabanı bu güce yükseltildiğinde sonlu değer olarak gösterebileceği maksimum negatif tam sayı üssünü döndürür. |
| quiet_NaN | Türü için bir sayı (NAN) değil sessiz gösterimini döndürür. |
| kök | Bir türün gösterimi için kullanılan ve radix olarak adlandırılan integral tabanını döndürür. |
| round_error | Tür için en yüksek yuvarlama hatasını döndürür. |
| round_style | Bir uygulamanın kayan nokta değerini tamsayı değerine yuvarlama için seçebileceği çeşitli yöntemleri açıklayan bir değer döndürür. |
| signaling_NaN | Tür için sayı (NAN) değil sinyal gösterimini döndürür. |
| tinyness_before | Bir türün, bir değeri yuvarlamadan önce normalleştirilmiş değer olarak temsil edilemeyecek kadar küçük olup olmadığını belirleyip belirleyemeyeceğini test eder. |
| Tuzak | Aritmetik özel durumlarla ilgili raporları yakalamanın bir tür için uygulanıp uygulanmadığını test eder. |
denorm_min
Sıfır olmayan en küçük normalleştirilmiş değeri döndürür.
static constexpr Type denorm_min() throw();
Dönüş Değeri
Sıfır olmayan en küçük normalleştirilmiş değer.
Açıklamalar
long double , C++ derleyicisi ile aynıdır double .
işlevi türü için en düşük değeri döndürür ve has_denorm değerine eşit değilse min değeriyle denorm_presentaynıdır.
Örnek
// numeric_limits_denorm_min.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "The smallest nonzero denormalized value" << endl
<< "for float objects is: "
<< numeric_limits<float>::denorm_min( ) << endl;
cout << "The smallest nonzero denormalized value" << endl
<< "for double objects is: "
<< numeric_limits<double>::denorm_min( ) << endl;
cout << "The smallest nonzero denormalized value" << endl
<< "for long double objects is: "
<< numeric_limits<long double>::denorm_min( ) << endl;
// A smaller value will round to zero
cout << numeric_limits<float>::denorm_min( )/2 <<endl;
cout << numeric_limits<double>::denorm_min( )/2 <<endl;
cout << numeric_limits<long double>::denorm_min( )/2 <<endl;
}
The smallest nonzero denormalized value
for float objects is: 1.4013e-045
The smallest nonzero denormalized value
for double objects is: 4.94066e-324
The smallest nonzero denormalized value
for long double objects is: 4.94066e-324
0
0
0
rakamlar
Türün duyarlık kaybı olmadan gösterebileceği radix basamaklarının sayısını döndürür.
static constexpr int digits = 0;
Dönüş Değeri
Türün duyarlık kaybı olmadan gösterebileceği radix basamaklarının sayısı.
Açıklamalar
Üye, türün değişiklik olmadan gösterebileceği radix basamaklarının sayısını depolar. Bu sayı, önceden tanımlanmış bir tamsayı türü için herhangi bir işaret biti dışındaki bitlerin sayısı veya önceden tanımlanmış kayan nokta türü için mantis basamaklarının sayısıdır.
Örnek
// numeric_limits_digits_min.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << numeric_limits<float>::digits <<endl;
cout << numeric_limits<double>::digits <<endl;
cout << numeric_limits<long double>::digits <<endl;
cout << numeric_limits<int>::digits <<endl;
cout << numeric_limits<__int64>::digits <<endl;
}
24
53
53
31
63
rakamlar10
Türün duyarlık kaybı olmadan gösterebileceği ondalık basamak sayısını döndürür.
static constexpr int digits10 = 0;
Dönüş Değeri
Türün duyarlık kaybı olmadan gösterebileceği ondalık basamak sayısı.
Örnek
// numeric_limits_digits10.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << numeric_limits<float>::digits10 <<endl;
cout << numeric_limits<double>::digits10 <<endl;
cout << numeric_limits<long double>::digits10 <<endl;
cout << numeric_limits<int>::digits10 <<endl;
cout << numeric_limits<__int64>::digits10 <<endl;
float f = (float)99999999;
cout.precision ( 10 );
cout << "The float is; " << f << endl;
}
6
15
15
9
18
The float is; 100000000
Epsilon
İşlev, veri türü için temsil edilebilen 1 ile 1'den büyük en küçük değer arasındaki farkı döndürür.
static constexpr Type epsilon() throw();
Dönüş Değeri
1 ile 1'den büyük olan ve veri türü için temsil edilebilen en küçük değer arasındaki fark.
Açıklamalar
değeri türü floatiçin FLT_EPSILON. epsilonbir tür için en küçük pozitif kayan nokta N sayısıdır ve N N + epsilon + temsil edilebilir.
Örnek
// numeric_limits_epsilon.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "The difference between 1 and the smallest "
<< "value greater than 1" << endl
<< "for float objects is: "
<< numeric_limits<float>::epsilon( ) << endl;
cout << "The difference between 1 and the smallest "
<< "value greater than 1" << endl
<< "for double objects is: "
<< numeric_limits<double>::epsilon( ) << endl;
cout << "The difference between 1 and the smallest "
<< "value greater than 1" << endl
<< "for long double objects is: "
<< numeric_limits<long double>::epsilon( ) << endl;
}
The difference between 1 and the smallest value greater than 1
for float objects is: 1.19209e-007
The difference between 1 and the smallest value greater than 1
for double objects is: 2.22045e-016
The difference between 1 and the smallest value greater than 1
for long double objects is: 2.22045e-016
has_denorm
Bir türün normalleştirilmiş değerlere izin verip vermeyeceğini test eder.
static constexpr float_denorm_style has_denorm = denorm_absent;
Dönüş Değeri
türündeki bir numaralandırma değeri, türün const float_denorm_stylenormalleştirilmiş değerlere izin verip vermeyeceğini belirtir.
Açıklamalar
Üye, normal olmayan değerlere sahip kayan nokta türü için depolar denorm_present ve etkili bir şekilde değişken sayıda üs biti depolar.
Örnek
// numeric_limits_has_denorm.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float objects allow denormalized values: "
<< numeric_limits<float>::has_denorm
<< endl;
cout << "Whether double objects allow denormalized values: "
<< numeric_limits<double>::has_denorm
<< endl;
cout << "Whether long int objects allow denormalized values: "
<< numeric_limits<long int>::has_denorm
<< endl;
}
Whether float objects allow denormalized values: 1
Whether double objects allow denormalized values: 1
Whether long int objects allow denormalized values: 0
has_denorm_loss
Kesinlik kaybının, kesin olmayan bir sonuç olarak değil, normalleştirme kaybı olarak algılanıp algılanamadığnı test eder.
static constexpr bool has_denorm_loss = false;
Dönüş Değeri
true doğruluk kaybı bir normalleştirme kaybı olarak algılanırsa; false değilse.
Açıklamalar
Üye, bir değerin normalleştirilmiş bir sonuç olarak teslim edildiğinden (normalleştirilmiş değer olarak temsil edilemeyecek kadar küçük olduğundan) veya açık olmadığından (sonuç olarak üs aralığı ve duyarlık sınırlamalarına tabi olmayan bir sonuçla aynı değildir), bazı sonuçları etkileyebilecek IEC 559 kayan nokta gösterimleri içeren bir seçenek olup olmadığını belirleyen bir tür için true depolar.
Örnek
// numeric_limits_has_denorm_loss.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float objects can detect denormalized loss: "
<< numeric_limits<float>::has_denorm_loss
<< endl;
cout << "Whether double objects can detect denormalized loss: "
<< numeric_limits<double>::has_denorm_loss
<< endl;
cout << "Whether long int objects can detect denormalized loss: "
<< numeric_limits<long int>::has_denorm_loss
<< endl;
}
Whether float objects can detect denormalized loss: 1
Whether double objects can detect denormalized loss: 1
Whether long int objects can detect denormalized loss: 0
has_infinity
Bir türün pozitif sonsuzluk gösterimi olup olmadığını test eder.
static constexpr bool has_infinity = false;
Dönüş Değeri
true türün pozitif sonsuzluk için bir gösterimi varsa; false değilse.
Açıklamalar
üye, is_iec559 ise truedöndürürtrue.
Örnek
// numeric_limits_has_infinity.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float objects have infinity: "
<< numeric_limits<float>::has_infinity
<< endl;
cout << "Whether double objects have infinity: "
<< numeric_limits<double>::has_infinity
<< endl;
cout << "Whether long int objects have infinity: "
<< numeric_limits<long int>::has_infinity
<< endl;
}
Whether float objects have infinity: 1
Whether double objects have infinity: 1
Whether long int objects have infinity: 0
has_quiet_NaN
Bir türün, işaretsiz olan bir sayı (NAN) değil de sessiz bir gösterime sahip olup olmadığını sınar.
static constexpr bool has_quiet_NaN = false;
Dönüş Değeri
truetürü sessiz BIR NAN için bir gösterime sahipse; false değilse.
Açıklamalar
Sessiz NAN, bir ifadedeki varlığının sinyalini vermeyen bir sayı için kodlamadır. dönüş değeri, true is_iec559 true ise olur.
Örnek
// numeric_limits_has_quiet_nan.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float objects have quiet_NaN: "
<< numeric_limits<float>::has_quiet_NaN
<< endl;
cout << "Whether double objects have quiet_NaN: "
<< numeric_limits<double>::has_quiet_NaN
<< endl;
cout << "Whether long int objects have quiet_NaN: "
<< numeric_limits<long int>::has_quiet_NaN
<< endl;
}
Whether float objects have quiet_NaN: 1
Whether double objects have quiet_NaN: 1
Whether long int objects have quiet_NaN: 0
has_signaling_NaN
Bir türün sayı (NAN) değil sinyal için bir gösterimi olup olmadığını sınar.
static constexpr bool has_signaling_NaN = false;
Dönüş Değeri
true türünde sinyal içeren BIR NAN için bir gösterim varsa; false değilse.
Açıklamalar
Sinyal veren NAN, bir sayı için değil, bir ifadedeki varlığını belirten bir kodlamadır. dönüş değeri, true is_iec559 true ise olur.
Örnek
// numeric_limits_has_signaling_nan.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float objects have a signaling_NaN: "
<< numeric_limits<float>::has_signaling_NaN
<< endl;
cout << "Whether double objects have a signaling_NaN: "
<< numeric_limits<double>::has_signaling_NaN
<< endl;
cout << "Whether long int objects have a signaling_NaN: "
<< numeric_limits<long int>::has_signaling_NaN
<< endl;
}
Whether float objects have a signaling_NaN: 1
Whether double objects have a signaling_NaN: 1
Whether long int objects have a signaling_NaN: 0
sonsuzluk
Varsa, bir tür için pozitif sonsuzluğun gösterimi.
static constexpr Type infinity() throw();
Dönüş Değeri
Varsa, bir tür için pozitif sonsuzluğun gösterimi.
Açıklamalar
Dönüş değeri yalnızca has_infinity ise anlamlıdırtrue.
Örnek
// numeric_limits_infinity.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << numeric_limits<float>::has_infinity <<endl;
cout << numeric_limits<double>::has_infinity<<endl;
cout << numeric_limits<long double>::has_infinity <<endl;
cout << numeric_limits<int>::has_infinity <<endl;
cout << numeric_limits<__int64>::has_infinity <<endl;
cout << "The representation of infinity for type float is: "
<< numeric_limits<float>::infinity( ) <<endl;
cout << "The representation of infinity for type double is: "
<< numeric_limits<double>::infinity( ) <<endl;
cout << "The representation of infinity for type long double is: "
<< numeric_limits<long double>::infinity( ) <<endl;
}
1
1
1
0
0
The representation of infinity for type float is: inf
The representation of infinity for type double is: inf
The representation of infinity for type long double is: inf
is_bounded
Bir türün gösterebileceği değer kümesinin sınırlı olup olmadığını test eder.
static constexpr bool is_bounded = false;
Dönüş Değeri
true türünde sınırlanmış bir temsil edilebilir değerler kümesi varsa; false değilse.
Açıklamalar
Önceden tanımlanmış tüm türlerin sınırlanmış bir temsil edilebilir değerler kümesi vardır ve döndürür true.
Örnek
// numeric_limits_is_bounded.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float objects have bounded set "
<< "of representable values: "
<< numeric_limits<float>::is_bounded
<< endl;
cout << "Whether double objects have bounded set "
<< "of representable values: "
<< numeric_limits<double>::is_bounded
<< endl;
cout << "Whether long int objects have bounded set "
<< "of representable values: "
<< numeric_limits<long int>::is_bounded
<< endl;
cout << "Whether unsigned char objects have bounded set "
<< "of representable values: "
<< numeric_limits<unsigned char>::is_bounded
<< endl;
}
Whether float objects have bounded set of representable values: 1
Whether double objects have bounded set of representable values: 1
Whether long int objects have bounded set of representable values: 1
Whether unsigned char objects have bounded set of representable values: 1
is_exact
Bir tür üzerinde yapılan hesaplamalarda yuvarlama hatası olup olmadığını test eder.
static constexpr bool is_exact = false;
Dönüş Değeri
true hesaplamalarda yuvarlama hatası yoksa; false değilse.
Açıklamalar
Önceden tanımlanmış tüm tamsayı türlerinin değerleri için tam gösterimleri vardır ve döndürür false. Sabit noktalı veya rasyonel bir gösterim de tam olarak kabul edilir, ancak kayan nokta gösterimi değildir.
Örnek
// numeric_limits_is_exact.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float objects have calculations "
<< "free of rounding errors: "
<< numeric_limits<float>::is_exact
<< endl;
cout << "Whether double objects have calculations "
<< "free of rounding errors: "
<< numeric_limits<double>::is_exact
<< endl;
cout << "Whether long int objects have calculations "
<< "free of rounding errors: "
<< numeric_limits<long int>::is_exact
<< endl;
cout << "Whether unsigned char objects have calculations "
<< "free of rounding errors: "
<< numeric_limits<unsigned char>::is_exact
<< endl;
}
Whether float objects have calculations free of rounding errors: 0
Whether double objects have calculations free of rounding errors: 0
Whether long int objects have calculations free of rounding errors: 1
Whether unsigned char objects have calculations free of rounding errors: 1
is_iec559
Bir türün IEC 559 standartlarına uygun olup olmadığını test eder.
static constexpr bool is_iec559 = false;
Dönüş Değeri
true türü IEC 559 standartlarına uygunsa; false değilse.
Açıklamalar
IEC 559, kayan nokta değerlerini temsil eden uluslararası bir standarttır ve ABD'de IEEE 754 olarak da bilinir.
Örnek
// numeric_limits_is_iec559.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float objects conform to iec559 standards: "
<< numeric_limits<float>::is_iec559
<< endl;
cout << "Whether double objects conform to iec559 standards: "
<< numeric_limits<double>::is_iec559
<< endl;
cout << "Whether int objects conform to iec559 standards: "
<< numeric_limits<int>::is_iec559
<< endl;
cout << "Whether unsigned char objects conform to iec559 standards: "
<< numeric_limits<unsigned char>::is_iec559
<< endl;
}
Whether float objects conform to iec559 standards: 1
Whether double objects conform to iec559 standards: 1
Whether int objects conform to iec559 standards: 0
Whether unsigned char objects conform to iec559 standards: 0
is_integer
Bir türün tamsayı gösterimi olup olmadığını sınar.
static constexpr bool is_integer = false;
Dönüş Değeri
true türünde tamsayı gösterimi varsa; false değilse.
Açıklamalar
Önceden tanımlanmış tüm tamsayı türlerinin bir tamsayı gösterimi vardır.
Örnek
// numeric_limits_is_integer.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float objects have an integral representation: "
<< numeric_limits<float>::is_integer
<< endl;
cout << "Whether double objects have an integral representation: "
<< numeric_limits<double>::is_integer
<< endl;
cout << "Whether int objects have an integral representation: "
<< numeric_limits<int>::is_integer
<< endl;
cout << "Whether unsigned char objects have an integral representation: "
<< numeric_limits<unsigned char>::is_integer
<< endl;
}
Whether float objects have an integral representation: 0
Whether double objects have an integral representation: 0
Whether int objects have an integral representation: 1
Whether unsigned char objects have an integral representation: 1
is_modulo
Bir türün modulo gösterimi olup olmadığını sınar.
static constexpr bool is_modulo = false;
Dönüş Değeri
true türün modulo gösterimi varsa; false değilse.
Açıklamalar
Modulo gösterimi, tüm sonuçların bir değer modülünü azalttığı bir gösterimdir. Önceden tanımlanmış tüm işaretsiz tamsayı türlerinin modulo gösterimi vardır.
Örnek
// numeric_limits_is_modulo.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float objects have a modulo representation: "
<< numeric_limits<float>::is_modulo
<< endl;
cout << "Whether double objects have a modulo representation: "
<< numeric_limits<double>::is_modulo
<< endl;
cout << "Whether signed char objects have a modulo representation: "
<< numeric_limits<signed char>::is_modulo
<< endl;
cout << "Whether unsigned char objects have a modulo representation: "
<< numeric_limits<unsigned char>::is_modulo
<< endl;
}
Whether float objects have a modulo representation: 0
Whether double objects have a modulo representation: 0
Whether signed char objects have a modulo representation: 1
Whether unsigned char objects have a modulo representation: 1
is_signed
Bir türün imzalı gösterimi olup olmadığını sınar.
static constexpr bool is_signed = false;
Dönüş Değeri
true türün imzalı bir gösterimi varsa; false değilse.
Açıklamalar
Üye, önceden tanımlanmış tüm kayan nokta ve imzalı tamsayı türleri için geçerli olan, imzalı gösterimi olan bir tür için true depolar.
Örnek
// numeric_limits_is_signaled.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float objects have a signed representation: "
<< numeric_limits<float>::is_signed
<< endl;
cout << "Whether double objects have a signed representation: "
<< numeric_limits<double>::is_signed
<< endl;
cout << "Whether signed char objects have a signed representation: "
<< numeric_limits<signed char>::is_signed
<< endl;
cout << "Whether unsigned char objects have a signed representation: "
<< numeric_limits<unsigned char>::is_signed
<< endl;
}
Whether float objects have a signed representation: 1
Whether double objects have a signed representation: 1
Whether signed char objects have a signed representation: 1
Whether unsigned char objects have a signed representation: 0
is_specialized
Bir türün sınıf şablonunda numeric_limitstanımlanmış açık bir özelleştirmesi olup olmadığını sınar.
static constexpr bool is_specialized = false;
Dönüş Değeri
true türü sınıf şablonunda tanımlanmış açık bir özelleştirmeye sahipse; false değilse.
Açıklamalar
İşaretçiler dışındaki tüm skaler türleri, sınıf şablonu numeric_limitsiçin tanımlanmış açık bir özelleştirmeye sahiptir.
Örnek
// numeric_limits_is_specialized.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float objects have an explicit "
<< "specialization in the class: "
<< numeric_limits<float>::is_specialized
<< endl;
cout << "Whether float* objects have an explicit "
<< "specialization in the class: "
<< numeric_limits<float*>::is_specialized
<< endl;
cout << "Whether int objects have an explicit "
<< "specialization in the class: "
<< numeric_limits<int>::is_specialized
<< endl;
cout << "Whether int* objects have an explicit "
<< "specialization in the class: "
<< numeric_limits<int*>::is_specialized
<< endl;
}
Whether float objects have an explicit specialization in the class: 1
Whether float* objects have an explicit specialization in the class: 0
Whether int objects have an explicit specialization in the class: 1
Whether int* objects have an explicit specialization in the class: 0
en düşük
En negatif sonlu değeri döndürür.
static constexpr Type lowest() throw();
Dönüş Değeri
En negatif sonlu değeri döndürür.
Açıklamalar
Türün (genellikle min() tamsayı türleri ve -max() kayan nokta türleri için) en negatif sonlu değeri döndürür. dönüş değeri ise is_bounded anlamlıdır true.
max
Bir tür için en yüksek sonlu değeri döndürür.
static constexpr Type max() throw();
Dönüş Değeri
Bir tür için en büyük sonlu değer.
Açıklamalar
En büyük sonlu değer türü için INT_MAX ve türü int floatiçin FLT_MAX. is_bounded ise dönüş değeri anlamlıdırtrue.
Örnek
// numeric_limits_max.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main() {
cout << "The maximum value for type float is: "
<< numeric_limits<float>::max( )
<< endl;
cout << "The maximum value for type double is: "
<< numeric_limits<double>::max( )
<< endl;
cout << "The maximum value for type int is: "
<< numeric_limits<int>::max( )
<< endl;
cout << "The maximum value for type short int is: "
<< numeric_limits<short int>::max( )
<< endl;
}
max_digits10
Türün iki ayrı değerinin ayrı ondalık gösterimleri olduğundan emin olmak için gereken ondalık basamak sayısını döndürür.
static constexpr int max_digits10 = 0;
Dönüş Değeri
Türün iki ayrı değerinin ayrı ondalık gösterimleri olduğundan emin olmak için gereken ondalık basamak sayısını döndürür.
Açıklamalar
Üye, türün iki ayrı değerinin ayrı ondalık gösterimleri olduğundan emin olmak için gereken ondalık basamak sayısını depolar.
max_exponent
Kayan nokta türünün bir radik tabanı bu güce yükseltildiğinde sonlu değer olarak gösterebileceği maksimum pozitif tamsayı üssünü döndürür.
static constexpr int max_exponent = 0;
Dönüş Değeri
Türüyle temsil edilebilen en büyük integral radix tabanlı üs.
Açıklamalar
Üye işlevi dönüşü yalnızca kayan nokta türleri için anlamlıdır. max_exponent türü floatiçin FLT_MAX_EXP değeridir.
Örnek
// numeric_limits_max_exponent.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "The maximum radix-based exponent for type float is: "
<< numeric_limits<float>::max_exponent
<< endl;
cout << "The maximum radix-based exponent for type double is: "
<< numeric_limits<double>::max_exponent
<< endl;
cout << "The maximum radix-based exponent for type long double is: "
<< numeric_limits<long double>::max_exponent
<< endl;
}
The maximum radix-based exponent for type float is: 128
The maximum radix-based exponent for type double is: 1024
The maximum radix-based exponent for type long double is: 1024
max_exponent10
Kayan nokta türünün, on tabanı bu güce yükseltildiğinde sonlu değer olarak gösterebileceği maksimum pozitif tamsayı üssünü döndürür.
static constexpr int max_exponent10 = 0;
Dönüş Değeri
Türüne göre temsil edilebilen en büyük tam sayı tabanı 10 üs.
Açıklamalar
Üye işlevi dönüşü yalnızca kayan nokta türleri için anlamlıdır. max_exponent türü floatiçin FLT_MAX_10 değeridir.
Örnek
// numeric_limits_max_exponent10.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "The maximum base 10 exponent for type float is: "
<< numeric_limits<float>::max_exponent10
<< endl;
cout << "The maximum base 10 exponent for type double is: "
<< numeric_limits<double>::max_exponent10
<< endl;
cout << "The maximum base 10 exponent for type long double is: "
<< numeric_limits<long double>::max_exponent10
<< endl;
}
The maximum base 10 exponent for type float is: 38
The maximum base 10 exponent for type double is: 308
The maximum base 10 exponent for type long double is: 308
dk
Bir tür için en düşük normalleştirilmiş değeri döndürür.
static constexpr Type min() throw();
Dönüş Değeri
Türü için en düşük normalleştirilmiş değer.
Açıklamalar
En düşük normalleştirilmiş değer türü için INT_MIN ve türü int floatiçin FLT_MIN. is_bounded veya is_signed true ise dönüş değeri anlamlıdırfalse.
Örnek
// numeric_limits_min.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "The minimum value for type float is: "
<< numeric_limits<float>::min( )
<< endl;
cout << "The minimum value for type double is: "
<< numeric_limits<double>::min( )
<< endl;
cout << "The minimum value for type int is: "
<< numeric_limits<int>::min( )
<< endl;
cout << "The minimum value for type short int is: "
<< numeric_limits<short int>::min( )
<< endl;
}
The minimum value for type float is: 1.17549e-038
The minimum value for type double is: 2.22507e-308
The minimum value for type int is: -2147483648
The minimum value for type short int is: -32768
min_exponent
Bir sayı tabanı bu güce yükseltildiğinde kayan nokta türünün sonlu değer olarak gösterebileceği maksimum negatif tam sayı üssünü döndürür.
static constexpr int min_exponent = 0;
Dönüş Değeri
Türüyle temsil edilebilen en düşük integral radix tabanlı üs.
Açıklamalar
Üye işlevi yalnızca kayan nokta türleri için anlamlıdır. min_exponent türü floatiçin FLT_MIN_EXP değeridir.
Örnek
// numeric_limits_min_exponent.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "The minimum radix-based exponent for type float is: "
<< numeric_limits<float>::min_exponent
<< endl;
cout << "The minimum radix-based exponent for type double is: "
<< numeric_limits<double>::min_exponent
<< endl;
cout << "The minimum radix-based exponent for type long double is: "
<< numeric_limits<long double>::min_exponent
<< endl;
}
The minimum radix-based exponent for type float is: -125
The minimum radix-based exponent for type double is: -1021
The minimum radix-based exponent for type long double is: -1021
min_exponent10
Kayan nokta türünün, on tabanı bu güce yükseltildiğinde sonlu değer olarak gösterebileceği maksimum negatif tam sayı üssünü döndürür.
static constexpr int min_exponent10 = 0;
Dönüş Değeri
Türüyle temsil edilebilen en düşük tam sayı tabanı 10 üssü.
Açıklamalar
Üye işlevi yalnızca kayan nokta türleri için anlamlıdır. min_exponent10 türü floatiçin FLT_MIN_10_EXP değeridir.
Örnek
// numeric_limits_min_exponent10.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "The minimum base 10 exponent for type float is: "
<< numeric_limits<float>::min_exponent10
<< endl;
cout << "The minimum base 10 exponent for type double is: "
<< numeric_limits<double>::min_exponent10
<< endl;
cout << "The minimum base 10 exponent for type long double is: "
<< numeric_limits<long double>::min_exponent10
<< endl;
}
The minimum base 10 exponent for type float is: -37
The minimum base 10 exponent for type double is: -307
The minimum base 10 exponent for type long double is: -307
quiet_NaN
Türü için bir sayı (NAN) değil sessiz gösterimini döndürür.
static constexpr Type quiet_NaN() throw();
Dönüş Değeri
Türü için sessiz bir NAN gösterimi.
Açıklamalar
Dönüş değeri yalnızca has_quiet_NaN ise anlamlıdırtrue.
Örnek
// numeric_limits_quiet_nan.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "The quiet NaN for type float is: "
<< numeric_limits<float>::quiet_NaN( )
<< endl;
cout << "The quiet NaN for type int is: "
<< numeric_limits<int>::quiet_NaN( )
<< endl;
cout << "The quiet NaN for type long double is: "
<< numeric_limits<long double>::quiet_NaN( )
<< endl;
}
The quiet NaN for type float is: 1.#QNAN
The quiet NaN for type int is: 0
The quiet NaN for type long double is: 1.#QNAN
kök
Bir türün gösterimi için kullanılan ve radix olarak adlandırılan integral tabanını döndürür.
static constexpr int radix = 0;
Dönüş Değeri
Türün gösterimi için tam sayı tabanı.
Açıklamalar
Taban, önceden tanımlanmış tamsayı türleri için 2, üssün yükseltildiği taban veya önceden tanımlanmış kayan nokta türleri için FLT_RADIX.
Örnek
// numeric_limits_radix.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "The base for type float is: "
<< numeric_limits<float>::radix
<< endl;
cout << "The base for type int is: "
<< numeric_limits<int>::radix
<< endl;
cout << "The base for type long double is: "
<< numeric_limits<long double>::radix
<< endl;
}
The base for type float is: 2
The base for type int is: 2
The base for type long double is: 2
round_error
Tür için en yüksek yuvarlama hatasını döndürür.
static constexpr Type round_error() throw();
Dönüş Değeri
Tür için en yüksek yuvarlama hatası.
Örnek
// numeric_limits_round_error.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "The maximum rounding error for type float is: "
<< numeric_limits<float>::round_error( )
<< endl;
cout << "The maximum rounding error for type int is: "
<< numeric_limits<int>::round_error( )
<< endl;
cout << "The maximum rounding error for type long double is: "
<< numeric_limits<long double>::round_error( )
<< endl;
}
The maximum rounding error for type float is: 0.5
The maximum rounding error for type int is: 0
The maximum rounding error for type long double is: 0.5
round_style
Bir uygulamanın kayan nokta değerini tamsayı değerine yuvarlama için seçebileceği çeşitli yöntemleri açıklayan bir değer döndürür.
static constexpr float_round_style round_style = round_toward_zero;
Dönüş Değeri
Numaralandırmadan float_round_style yuvarlama stilini açıklayan bir değer.
Açıklamalar
Üye, bir uygulamanın kayan nokta değerini tamsayı değerine yuvarlama için seçebileceği çeşitli yöntemleri açıklayan bir değer depolar.
Yuvarlama stili bu uygulamada sabit kodlanmıştır, dolayısıyla program farklı bir yuvarlama moduyla başlasa bile bu değer değişmez.
Örnek
// numeric_limits_round_style.cpp
// compile with: /EHsc
#include <iostream>
#include <float.h>
#include <limits>
using namespace std;
int main( )
{
cout << "The rounding style for a double type is: "
<< numeric_limits<double>::round_style << endl;
_controlfp_s(NULL,_RC_DOWN,_MCW_RC );
cout << "The rounding style for a double type is now: "
<< numeric_limits<double>::round_style << endl;
cout << "The rounding style for an int type is: "
<< numeric_limits<int>::round_style << endl;
}
The rounding style for a double type is: 1
The rounding style for a double type is now: 1
The rounding style for an int type is: 0
signaling_NaN
Tür için sayı (NAN) değil sinyal gösterimini döndürür.
static constexpr Type signaling_NaN() throw();
Dönüş Değeri
Türü için sinyal nan temsili.
Açıklamalar
Dönüş değeri yalnızca has_signaling_NaN ise anlamlıdırtrue.
Örnek
// numeric_limits_signaling_nan.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "The signaling NaN for type float is: "
<< numeric_limits<float>::signaling_NaN( )
<< endl;
cout << "The signaling NaN for type int is: "
<< numeric_limits<int>::signaling_NaN( )
<< endl;
cout << "The signaling NaN for type long double is: "
<< numeric_limits<long double>::signaling_NaN( )
<< endl;
}
tinyness_before
Bir türün, bir değeri yuvarlamadan önce normalleştirilmiş değer olarak temsil edilemeyecek kadar küçük olup olmadığını belirleyip belirleyemeyeceğini test eder.
static constexpr bool tinyness_before = false;
Dönüş Değeri
true tür yuvarlamadan önce küçük değerleri algılayabilirse; false eğer yapamazsa.
Açıklamalar
Küçüklüğü algılayan türler IEC 559 kayan nokta gösterimlerine bir seçenek olarak dahil edildi ve uygulanması bazı sonuçları etkileyebilir.
Örnek
// numeric_limits_tinyness_before.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float types can detect tinyness before rounding: "
<< numeric_limits<float>::tinyness_before
<< endl;
cout << "Whether double types can detect tinyness before rounding: "
<< numeric_limits<double>::tinyness_before
<< endl;
cout << "Whether long int types can detect tinyness before rounding: "
<< numeric_limits<long int>::tinyness_before
<< endl;
cout << "Whether unsigned char types can detect tinyness before rounding: "
<< numeric_limits<unsigned char>::tinyness_before
<< endl;
}
Whether float types can detect tinyness before rounding: 1
Whether double types can detect tinyness before rounding: 1
Whether long int types can detect tinyness before rounding: 0
Whether unsigned char types can detect tinyness before rounding: 0
tuzaklar
Aritmetik özel durumlarla ilgili raporları yakalamanın bir tür için uygulanıp uygulanmadığını test eder.
static constexpr bool traps = false;
Dönüş Değeri
true türü için yakalama uygulandıysa; false değilse.
Örnek
// numeric_limits_traps.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << "Whether float types have implemented trapping: "
<< numeric_limits<float>::traps
<< endl;
cout << "Whether double types have implemented trapping: "
<< numeric_limits<double>::traps
<< endl;
cout << "Whether long int types have implemented trapping: "
<< numeric_limits<long int>::traps
<< endl;
cout << "Whether unsigned char types have implemented trapping: "
<< numeric_limits<unsigned char>::traps
<< endl;
}
Whether float types have implemented trapping: 1
Whether double types have implemented trapping: 1
Whether long int types have implemented trapping: 0
Whether unsigned char types have implemented trapping: 0