C++[常用數據轉換]

1.精度轉換

/// double轉換字符串
inline std::string transString(double d,int len) {
    int first = round(d * pow(10, len)) / pow(10, len);
    int last = round(d * pow(10, len)) - (first * pow(10, len));
    return to_string(first) + "." + to_string(abs(last));
}

2.

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章