> The Unit Test Framework > User's guide > Test Output > Test log > Logging floating point type numbers

###### Logging floating point type numbers

It may appear that floating-point numbers are displayed by the UTF with an excessive number of decimal digits. However the number of digits shown is chosen to avoid apparently nonsensical displays like `[1.00000 != 1.00000]` when comparing exactly unity against a value which is increased by just one least significant binary digit using the default precision for float of just 6 decimal digits, given by `std::numeric_limits`<float>::digits10. The function used for the number of decimal digits displayed is that proposed for a future C++ Standard, A Proposal to add a max significant decimal digits value, to be called `std::numeric_limits`::max_digits10();. For 32-bit floats, 9 decimal digits are needed to ensure a single bit change produces a different decimal digit string.
UTF 打印的浮點數可能會出現過多的小數位。 然而顯示的數字位數是選擇用來避免如 `[1.00000 != 1.00000]` 的無意義的顯示， 當根據 `std::numeric_limits`<float>::digits10 提供的默認的 6 位浮點精度，精確比較兩個數需要更低有意義的二進制位數時。(???) 用於顯示數字位數的函數是根據未來的 C++ 標準設定的， A Proposal to add a max significant decimal digits value，通過調用 `std::numeric_limits`::max_digits10();。 對於 32 浮點數，至少 9 位數字需要用來確保單個位的變化會產生不同的數字。

So a much more helpful display using 9 decimal digits is thus: `[1.00000000 != 1.00000012]` showing that the two values are in fact different.

For IEEE754 32-bit float values - 9 decimal digits are shown. For 64-bit IEEE754 double - 17 decimal digits. For IEEE754 extended long double using 80-bit - 21 decimal digits. For IEEE754 quadruple long double 128-bit, and Sparc extended long double 128-bit - 36 decimal digits. For floating-point types, a convenient formula to calculate max_digits10 is: 2 + `std::numeric_limits`<FPT>::digits * 3010/10000;

Note Note that a user defined floating point type UDFPT must define `std::numeric_limits`::is_specialized = true and provide an appropriate value for `std::numeric_limits`::digits, the number of bits used for the significand or mantissa. For example, for the Sparc extended long double 128, 113 bits are used for the significand (one of which is implicit). 定義自定義的浮點數類型 UDFPT 必須定義 `std::numeric_limits`::is_specialized = true， 並為 `std::numeric_limits`::digits 提供合適的值， 有意義的尾數使用的位數。 例如，對於 Sparc 的 128 位擴展長雙精度值，使用 113 位 (其中 1 位是隱式的)。