如何转换这个计算结果颤振
how to convert this result of calculation flutter
想知道如何像整数那样显示这个结果
var symbol = data[index]["symbol"];
double cureentprice = datarates["price"]["$symbol"];////this double is 1.17150
double enrty = double.parse(data[index]["entryprice"]);////this is 1.17100
double lo = cureentprice - enrty ;//i got like this result 0.00050
正如你在上面看到的,我得到了结果 0.00050,但我需要这样的结果 50
有没有想过做那样的事情??
试试这个。也许这应该有所帮助。如果这不起作用,请告诉我。
var symbol = data[index]["symbol"];
double cureentprice = datarates["price"]["$symbol"];////this double is 1.17150
double enrty = double.parse(data[index]["entryprice"]);////this is 1.17100
// double lo = cureentprice - enrty ;//i got like this result 0.00050
int scale = 100000;
double lo = currentPrice - enrty;
var value1 = (lo * scale).floor();
var value2 = (lo * scale).ceil();
print(value1);
print(value2);
您可以先缩放然后使用 floor() 或 ceil() 函数进行舍入以获得所需的输出。
double currentPrice = 1.17150;
double enrty = 1.17100;
int scale = 100000;
double lo = currentPrice - enrty;
print((lo * scale).floor()); //prints 49
print((lo * scale).ceil()); //prints 50
想知道如何像整数那样显示这个结果
var symbol = data[index]["symbol"];
double cureentprice = datarates["price"]["$symbol"];////this double is 1.17150
double enrty = double.parse(data[index]["entryprice"]);////this is 1.17100
double lo = cureentprice - enrty ;//i got like this result 0.00050
正如你在上面看到的,我得到了结果 0.00050,但我需要这样的结果 50
有没有想过做那样的事情??
试试这个。也许这应该有所帮助。如果这不起作用,请告诉我。
var symbol = data[index]["symbol"];
double cureentprice = datarates["price"]["$symbol"];////this double is 1.17150
double enrty = double.parse(data[index]["entryprice"]);////this is 1.17100
// double lo = cureentprice - enrty ;//i got like this result 0.00050
int scale = 100000;
double lo = currentPrice - enrty;
var value1 = (lo * scale).floor();
var value2 = (lo * scale).ceil();
print(value1);
print(value2);
您可以先缩放然后使用 floor() 或 ceil() 函数进行舍入以获得所需的输出。
double currentPrice = 1.17150;
double enrty = 1.17100;
int scale = 100000;
double lo = currentPrice - enrty;
print((lo * scale).floor()); //prints 49
print((lo * scale).ceil()); //prints 50