Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.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
Flutter 删除省道中的小数_Flutter_Dart - Fatal编程技术网

Flutter 删除省道中的小数

Flutter 删除省道中的小数,flutter,dart,Flutter,Dart,我有一个数字:466.62是双精度的,无法将其更改为字符串,如何去掉小数点并打印46662?通过将该值乘以100,我得到了46662.0,但我不想打印小数点。谢谢当你将466.62乘以100时,你的最终结果也将保持双倍。这就是您看到46662.0的原因。因此,您需要将其转换为Int值,因此您应该这样做: double vDouble = 466.62 *100 String vString = vDouble.toInt().toString(); 这将给你4662 对于更一般的情况,请使用字

我有一个数字:466.62是双精度的,无法将其更改为字符串,如何去掉小数点并打印46662?通过将该值乘以100,我得到了46662.0,但我不想打印小数点。谢谢

当你将466.62乘以100时,你的最终结果也将保持双倍。这就是您看到46662.0的原因。因此,您需要将其转换为Int值,因此您应该这样做:

double vDouble = 466.62 *100
String vString = vDouble.toInt().toString();
这将给你4662

对于更一般的情况,请使用字符串


在您成功获得这个46662.0之后

使用以下命令:

46662.0.toStringAsFixed(0)

print(46662.0.toStringAsFixed(0))-这是46662

print(46662.0.toStringAsFixed(0.runtimeType)-这以字符串形式给出

参考:

当然没有想到先创建变量,然后再添加.Int()!或者只需调用
.toInt()
,它将截断所有的十进制固定轮数,因此我认为你的答案不符合他的目的
String str = '466.62';

//split string
var arr = str.split('.');

print(arr[0]); //will print 466
print(are[1]); //will print 62