你可以通过创建DecimalFormat对象并设置相应的格式来保留两位小数。 java import java.text.DecimalFormat; double num = 3.1415926; DecimalFormat decimalFormat = new DecimalFormat("#.00"); // "#.00" 表示最多两位小数,不足时补零(这里不补零) String formattedNum = decimalFormat.format(num); System.out....
String num=df.format(hhao);
QString的静态函数number可以设置精度 QString QString::number(double n, char format = 'g', int precision = 6)Returns a string equivalent of the number n, formatted according to the specified format and precision. See Argument Formats for details.Unlike QLocale::toString(), this fun...
QString的静态函数number可以设置精度 QString QString::number(double n, char format = 'g', int precision = 6)Returns a string equivalent of the number n, formatted according to the specified format and precision. See Argument Formats for details.Unlike QLocale::toString(), this fun...
return String.format("Loan: %.2f", loan);