gpt4 book ai didi

flutter - Dart/Flutter-如何在格式化值时避免通过NumberFormat.compactCurrency(locale: “en_IN”).format()方法完成的自动舍入?

转载 作者:行者123 更新时间:2023-12-03 04:41:07 25 4
gpt4 key购买 nike

Dart / Flutter-如何在格式化值时如何避免通过NumberFormat.compactCurrency(locale:“en_IN”)。format()方法完成的自动舍入?

num value = 29886964;
NumberFormat numberFormat = NumberFormat.compactCurrency(locale: "en_IN");
String output = numberFormat.format(value);
实际产量= INR2.99Cr
需求/期望:INR2.98Cr

最佳答案

使用NumberFormat.currency API

num value = 29886964;
NumberFormat numberFormat = NumberFormat.compactCurrency(locale: "en_IN" );
final count = math.pow(10 , (value.toString().length - numberFormat.significantDigits));
var result = value / count;
String output = numberFormat.format(result.floor() * count);
print(output);
值:INR2.98Cr

关于flutter - Dart/Flutter-如何在格式化值时避免通过NumberFormat.compactCurrency(locale: “en_IN”).format()方法完成的自动舍入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63184725/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com