std::numeric_limits::digits10
来自cppreference.com
< cpp | types | numeric limits
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| static const int digits10 |
(至 C++11) | |
| static constexpr int digits10 |
(C++11 起) | |
std::numeric_limits<T>::digits10的值的數目10為底的位數,可以不改變,即,所表示的類型
10(radix)和向下調整.
T任何的第二個版本訂單存儲器訪問這麼多的小數位數的號碼可以轉換成一個值類型T為小數形式,沒有變化,由於四捨五入或溢出。基radix類型,它的價值是digits(digits-1浮點類型)乘以log10(radix)和向下調整.
Original:
The value of std::numeric_limits<T>::digits10 is the number of base-10 digits that can be represented by the type
10(radix) and rounded down.
T without change, that is, any number with this many decimal digits can be converted to a value of type T and back to decimal form, without change due to rounding or overflow. For base-radix types, it is the value of digits (digits-1 for floating-point types) multiplied by log10(radix) and rounded down.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 標準的專業
T
|
值的std::numeric_limits<T>::digits10
Original: value of std::numeric_limits<T>::digits10 The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| /* non-specialized */ | 0 |
| bool | 0 |
| char | std::numeric_limits<char>::digits * std::log10(2) |
| signed char | std::numeric_limits<signed char>::digits * std::log10(2) |
| unsigned char | std::numeric_limits<unsigned char>::digits * std::log10(2) |
| wchar_t | std::numeric_limits<wchar_t>::digits * std::log10(2) |
| char16_t | std::numeric_limits<char16_t>::digits * std::log10(2) |
| char32_t | std::numeric_limits<char32_t>::digits * std::log10(2) |
| short | std::numeric_limits<short>::digits * std::log10(2) |
| unsigned short | std::numeric_limits<signed short>::digits * std::log10(2) |
| int | std::numeric_limits<int>::digits * std::log10(2) |
| unsigned int | std::numeric_limits<signed int>::digits * std::log10(2) |
| long | std::numeric_limits<long>::digits * std::log10(2) |
| unsigned long | std::numeric_limits<unsigned long>::digits * std::log10(2) |
| long long | std::numeric_limits<long long>::digits * std::log10(2) |
| unsigned long long | std::numeric_limits<unsigned long long>::digits * std::log10(2) |
| float | FLT_DIG |
| double | DBL_DIG |
| long double | LDBL_DIG |
[编辑] 為例
一個8位二進制類型可以代表任何二位十進制數完全相同,但3位十進制數256。
digits10為一個8位的值是999不能派代表出席了會議。 (8 * std::log10(2)為2.41)Original:
An 8-bit binary type can represent any two-digit decimal number exactly, but 3-digit decimal numbers 256..999 cannot be represented. The value of
digits10 for an 8-bit type is 2 (8 * std::log10(2) is 2.41)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
標準的32位IEEE 754浮點類型都有一個24位的小數部分(23位寫,一個隱含的),這可能表明,它可以代表7位數字的小數(24 * std::log10(2)是7.22)。 ,但相對舍入誤差不統一,一些浮點值與7位小數尾數也沒有生存轉化為32位的持股量和回:的最小的正面例子是8.589973e9,變成8.589974e9後的往返。這些舍入誤差可以不超過
digits10,這是6.92 1位表示,(24-1)*std::log10(2)計算。向下取整結果值6.Original:
The standard 32-bit IEEE 754 floating-point type has a 24 bit fractional part (23 bits written, one implied), which may suggest that it can represent 7 digit decimals (24 * std::log10(2) is 7.22), but relative rounding errors are non-uniform and some floating-point values with 7 decimal digits do not survive conversion to 32-bit float and back: the smallest positive example is 8.589973e9, which becomes 8.589974e9 after the roundtrip. These rounding errors cannot exceed one bit in the representation, and
digits10 is calculated as (24-1)*std::log10(2), which is 6.92. Rounding down results in the value 6.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 另請參閱
| [靜態的] </ SPAN></div></div>
|
基數或用來表示給定類型的整數基地 Original: the radix or integer base used by the representation of the given type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共靜態成員常量) |
| [靜態的] </ SPAN></div></div>
|
radix數量的數字,可以表示沒有變化 Original: number of radix digits that can be represented without change The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共靜態成員常量) |
| [靜態的] </ SPAN></div></div>
|
一個比最小的負電源是一個有效的標準浮點值的基數 Original: one more than the smallest negative power of the radix that is a valid normalized floating-point value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共靜態成員常量) |
| [靜態的] </ SPAN></div></div>
|
一個比最大的整數次冪的基數是一個有效的有限浮點值 Original: one more than the largest integer power of the radix that is a valid finite floating-point value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共靜態成員常量) |