简体   繁体   English

如何转换此计算结果 flutter

[英]how to convert this result of calculation flutter

wanna know how to show this result like int number想知道如何显示这个结果,如 int number

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

as you see above i got the result 0.00050 but i need it like this 50正如你在上面看到的,我得到了 0.00050 的结果,但我需要这样的 50

any idea to do somthing like that??有什么想法做这样的事情吗?

Try This.尝试这个。 Maybe This should Help.也许这应该有所帮助。 If this doesn't work then let me know.如果这不起作用,请告诉我。

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);

You can first scale and then round-off using floor() or ceil() function to get desired output.您可以先缩放然后使用 floor() 或 ceil() function 进行四舍五入以获得所需的 output。

 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM