float fRealEsate = 360000.00 * 0.04;
Toast.makeText(v.getContext(), "Real Estate Brokerage Fee: "
+ fRealEsate, Toast.LENGTH_SHORT).show();
を探している私はそれが15600.00を表示する必要があるが、その上には読む15600.0floatが正しいフォーマットを表示していません。 xxxxxx.xx
float fRealEsate = 360000.00 * 0.04;
Toast.makeText(v.getContext(), "Real Estate Brokerage Fee: "
+ fRealEsate, Toast.LENGTH_SHORT).show();
を探している私はそれが15600.00を表示する必要があるが、その上には読む15600.0floatが正しいフォーマットを表示していません。 xxxxxx.xx
使用NumberFormatを。
String sRealEstate = NumberFormat.getCurrencyInstance().format(fRealEstate);
フロートではなく、トーストで書式設定された文字列バージョンを直接使用します。あなたはお金のためにfloatを使うべきではありません
float f = 123456.123456f;
NumberFormat nf = new DecimalFormat(".00");
System.out.println(nf.format(f));//123456.12
。お金は浮動小数点ではなく固定小数点です。ドルとセントを整数値として格納することを検討してください。 – DwB