我不明白.. Hello Guys! I need to round numbers with how many decimals i want, using C++ builder 6. I saw on google, that to do that i need the setprecision(), but i can''t show it on a Memo! But, when i click on button, shows it: 3,73456001281738 I don''t understand.. #include<iostream>#include<sstream>#include<iomanip>void __fastcall TForm1::Button1Click(TObject *Sender){ AnsiString strValue; setprecision(2); float value = 3.73456; strValue = FloatToStr(value); Memo1->Lines->Add(" " + strValue);} 如果我错过了什么,请纠正我。我是新来的。 谢谢!! PS *(对不起英语,我正在学习,所以。放轻松..)If i miss something, correct me please. I''m new here.Thanks!!PS* (sorry for the english, i''m learning, so.. take it easy..)推荐答案 使用 FloatToStrF [ ^ ]功能 你最好看看提升 [ ^ ]库。它有许多有用的数学函数。You better take a look at boost[^] library. Its with lots of useful mathematical functions. 这篇关于使用setprecision()进行舍入值的问题;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-25 21:44