Closed LaksamanaGuntur closed 5 years ago
English Version:
Hi @LaksamanaGuntur, actually this is not part of flutter_money_formatter
, the rounding results are obtained from the intl
dependency.
However, as far as I know, rounding will usually use the round-up / round-down method by referring to the number on the right. So if we pay attention, the reason number 12355678.9012345
becomes 12.40M
is, we will only take the first 4
digits (in your case that is, 1235
), and the fourth number is 5
, so the rounding method that will be used is definitely using the round-up
method, and the result of rounding up from 1235
is 1240
.
Remember, in the basic concept of rounding, the numbers 1,2,3,4 have definitely experienced round-down, and the numbers 5,6,7,8,9 have definitely been rounded up.
as an example:
525 = 500 717 = 700 1,250 = 1,300 2,781 = 2,800 4,524 = 4,500 5,359 = 5,400 6,168 = 6,000 + 100 + 68 = 6,000 + 100 + 100 = 6,200 6,998 = 6,000 + 900 + 98 = 6,000 + 900 + 100 = 7,000 10,343 = 10,000 + 300 + 43 = 10,000 + 300 + 0 = 10,300 7,423 = 7,400
Maybe if possible, in the next version I will add round-up and round-down features (by ignoring the basic concept of rounding numbers).
N.B: Please review the concept of rounding, and as an additional reference from me, (since you are Indonesian) this is a good article that discusses rounding numbers.
Versi Indonesia
Hi @LaksamanaGuntur , sebetulnya hal ini bukan merupakan bagian dari flutter_money_formatter, hasil pembulatan tersebut didapat dari dependency intl
.
Namun, sepanjang yang saya tau, pembulatan biasanya akan menggunakan metode pembulatan ke angka terdekat (round-up/round-down) dengan mengacu pada angka disebelah kanan. Jadi bila kita perhatikan, alasan angka 12355678.9012345
menjadi 12.40M
adalah, kita hanya akan mengambil 4
digit pertama (pada kasus Anda yakni, 1235
), dan angka ke-empat adalah 5
, sehingga metode pembulatan yang akan digunakan sudah pasti menggunakan metode round-up (pembulatan ke-atas) dan hasil pembulatan ke atas dari 1235 adalah 1240.
Ingat, pada konsep dasar pembulatan, angka 1,2,3,4 sudah pasti mengalami pembulatan round-down, dan angka 5,6,7,8,9 sudah pasti mengalami pembulatan ke-atas.
sebagai contoh:
525 = 500 717 = 700 1.250 = 1.300 2.781 = 2.800 4.524 = 4.500 5.359 = 5.400 6.168 = 6.000 + 100 + 68 = 6.000 + 100 + 100 = 6.200 6.998 = 6.000 + 900 + 98 = 6.000 + 900 + 100 = 7.000 10.343 = 10.000 + 300 + 43 = 10.000 + 300 + 0 = 10.300 7.423 = 7.400
Mungkin bila memungkinkan, pada versi berikutnya akan saya tambahkan fitur round-up dan round-down (dengan mengabaikan konsep dasar pembulatan angka).
N.B: Silahkan pelajari kembali konsep pembulatan, dan sebagai referensi tambahan dari saya, (berhubung Anda orang Indonesia) maka ini artikel bagus yang membahas mengenai pembulatan angka
Describe the bug I get a problem with rounding value
To Reproduce
your sample :
FlutterMoneyFormatter fmf = FlutterMoneyFormatter( amount: 12345678.9012345 ); and output with print(fo.compactNonSymbol); is12.30M
My sample :
i change amount with 12355678.9012345 (change number four to five) and output with print(fo.compactNonSymbol); is12.40M
Expected behavior My Expectation is
12.35
Screenshots
Smartphone (please complete the following information):
Thanks!