fix: fix float point error in show

This commit is contained in:
2023-12-14 04:10:27 +00:00
parent 67b681d1dd
commit 4cfbbc2991

View File

@ -240,7 +240,7 @@ std::vector<std::string> BookStoreEngineClass::ExecuteShow(
tmp += '\t';
tmp += i.keyword;
tmp += '\t';
unsigned long long price_tmp = i.price * 100;
unsigned long long price_tmp = i.price * 100 + 0.5;
tmp += std::to_string(price_tmp / 100) + "." +
std::to_string(price_tmp % 100 / 10) +
std::to_string(price_tmp % 10);