【发布时间】:2015-09-13 16:52:49
【问题描述】:
堆栈溢出和 C++ 的新手
std::cout << std::fixed << "Starting Balance: $" << std::setprecision(2) << startbal << endl;
std::cout<< "Annual Interest Rate: " << intrestrate << endl;
std::cout << std::fixed << "Monthly Payment: $" << std::setprecision(2) <<monthlypay << endl;
我在这里尝试从我拥有的数组中打印,它的打印大部分是正确的,但我需要第二行不受 setprecision 的影响,这样年利率就不会改变。
打印后我得到:
Starting Balance: $1000.00
Annual Interest Rate: 0.05
Monthly Payment: $120.00
但我需要它来停止将年利率四舍五入,因为它应该是 0.055。感谢您提前提供任何帮助!
【问题讨论】:
-
将其设置为您确实想要的精度......
标签: c++