Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 应用程序/游戏用钱柜台_Java - Fatal编程技术网

Java 应用程序/游戏用钱柜台

Java 应用程序/游戏用钱柜台,java,Java,我正在转换我的钱袋以容纳超过最大整数。我被困在这里: public String getFormattedValue(double value) { if (value >= 1000 && value < 10e+5) { return formatValue(value / 1000, 2) + "k"; } else if (value >= 10e+5 && value <= 10e+8) {

我正在转换我的钱袋以容纳超过最大整数。我被困在这里:

public String getFormattedValue(double value) {
    if (value >= 1000 && value < 10e+5) {
        return formatValue(value / 1000, 2) + "k";
    } else if (value >= 10e+5 && value <= 10e+8) {
        return formatValue(value / 10e+5, 3) + " million";
    } else if (value >= 10e+8 && value <= ***?***) {
        return formatValue(value / 10e+8, 3) + " billion";
    } else if (value >= ***?*** && value <= ***??***) {
        return formatValue(value / 10e+8, 3) + " trillion";
    } else {
        return formatValue(value, 2);
    }
}
公共字符串getFormattedValue(双值){
如果(值>=1000&&value<10e+5){
返回格式值(值/1000,2)+“k”;

}如果(value>=10e+5&&value=10e+8&&value=***?***&&value我不熟悉formatValue函数,但我认为您可以执行以下操作:

public String getFormattedValue(double value)
{

   long thousands = (long)(value / 1000);
   long millions = (long)(value / 1000000);
   long billions = (long)(value / 1000000000);
   long trillions = (long)(value / 1000000000000L);


   if (trillions > 0)
       return formatValue(trillions) + " trillion";
   else if (billions > 0)
       return formatValue(billions) + " billion";
   else if (millions > 0)
       return formatValue(millions) + " million";
   else if (thousands > 0)
       return formatValue(thousands) + " k";

   else
       return ("" + value);
}

尝试使用long代替。正如Luggi所建议的那样,long是存在的,甚至还有BigInteger:可能有帮助的数学方程是什么,比如“10e+8”=100万,以获得10亿=>
1000000000L