![](/img/trans.png)
[英]What is the meaning of numeric_limits<double>::digits10
[英]conversion from string to double with number greater than std::numeric_limit<double>::digits10
std::string str = "12345679012.124678";
double back = boost::lexical_cast<double>( str );
std::string str2 =boost::lexical_cast<std::string>( back );
//here str2 is equal to str
即使數字的有效位數大於std::numeric_limit<double>::digits10
(即15),這里是否正常(即最終字符串= orignal字符串)是否正常?
是的,這是正常的。
std::numeric_limit<double>::digits10
指的是保證鑄造沒有損失的最大位數。
這並不意味着使用比限制更多的數字而損失,只意味着損失的可能性增加。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.