File tree Expand file tree Collapse file tree 8 files changed +20
-6
lines changed Expand file tree Collapse file tree 8 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -2825,7 +2825,7 @@ class _BigIntImpl implements BigInt {
2825
2825
// There is already one in the cachedBits.
2826
2826
roundUp ();
2827
2827
} else {
2828
- for (int i = digitIndex; digitIndex >= 0 ; i-- ) {
2828
+ for (int i = digitIndex; i >= 0 ; i-- ) {
2829
2829
if (_digits[i] != 0 ) {
2830
2830
roundUp ();
2831
2831
break ;
Original file line number Diff line number Diff line change @@ -2738,7 +2738,7 @@ class _BigIntImpl implements BigInt {
2738
2738
// There is already one in the cachedBits.
2739
2739
roundUp ();
2740
2740
} else {
2741
- for (int i = digitIndex; digitIndex >= 0 ; i-- ) {
2741
+ for (int i = digitIndex; i >= 0 ; i-- ) {
2742
2742
if (_digits[i] != 0 ) {
2743
2743
roundUp ();
2744
2744
break ;
Original file line number Diff line number Diff line change @@ -2409,7 +2409,7 @@ class _BigIntImpl implements BigInt {
2409
2409
// There is already one in the cachedBits.
2410
2410
roundUp ();
2411
2411
} else {
2412
- for (int i = digitIndex; digitIndex >= 0 ; i-- ) {
2412
+ for (int i = digitIndex; i >= 0 ; i-- ) {
2413
2413
if (_digits[i] != 0 ) {
2414
2414
roundUp ();
2415
2415
break ;
Original file line number Diff line number Diff line change @@ -2830,7 +2830,7 @@ class _BigIntImpl implements BigInt {
2830
2830
// There is already one in the cachedBits.
2831
2831
roundUp ();
2832
2832
} else {
2833
- for (int i = digitIndex; digitIndex >= 0 ; i-- ) {
2833
+ for (int i = digitIndex; i >= 0 ; i-- ) {
2834
2834
if (_digits[i] != 0 ) {
2835
2835
roundUp ();
2836
2836
break ;
Original file line number Diff line number Diff line change @@ -2760,7 +2760,7 @@ class _BigIntImpl implements BigInt {
2760
2760
// There is already one in the cachedBits.
2761
2761
roundUp ();
2762
2762
} else {
2763
- for (int i = digitIndex; digitIndex >= 0 ; i-- ) {
2763
+ for (int i = digitIndex; i >= 0 ; i-- ) {
2764
2764
if (_digits[i] != 0 ) {
2765
2765
roundUp ();
2766
2766
break ;
Original file line number Diff line number Diff line change @@ -2413,7 +2413,7 @@ class _BigIntImpl implements BigInt {
2413
2413
// There is already one in the cachedBits.
2414
2414
roundUp ();
2415
2415
} else {
2416
- for (int i = digitIndex; digitIndex >= 0 ; i-- ) {
2416
+ for (int i = digitIndex; i >= 0 ; i-- ) {
2417
2417
if (_digits[i] != 0 ) {
2418
2418
roundUp ();
2419
2419
break ;
Original file line number Diff line number Diff line change @@ -1039,6 +1039,13 @@ void testFromToDouble() {
1039
1039
1040
1040
Expect .equals (BigInt .zero, new BigInt .from (0.9999999999999999 ));
1041
1041
Expect .equals (BigInt .zero, new BigInt .from (- 0.9999999999999999 ));
1042
+
1043
+ // Regression test for http://dartbug.com/41819
1044
+ // Rounding edge case where last digit causes rounding.
1045
+ Expect .equals (- 3.69616463331328e+27 ,
1046
+ BigInt .parse ("-3696164633313280000000000000" ).toDouble ());
1047
+ Expect .equals (- 3.6961646333132803e+27 ,
1048
+ BigInt .parse ("-3696164633313280000000000001" ).toDouble ());
1042
1049
}
1043
1050
1044
1051
main () {
Original file line number Diff line number Diff line change @@ -1039,6 +1039,13 @@ void testFromToDouble() {
1039
1039
1040
1040
Expect .equals (BigInt .zero, new BigInt .from (0.9999999999999999 ));
1041
1041
Expect .equals (BigInt .zero, new BigInt .from (- 0.9999999999999999 ));
1042
+
1043
+ // Regression test for http://dartbug.com/41819
1044
+ // Rounding edge case where last digit causes rounding.
1045
+ Expect .equals (- 3.69616463331328e+27 ,
1046
+ BigInt .parse ("-3696164633313280000000000000" ).toDouble ());
1047
+ Expect .equals (- 3.6961646333132803e+27 ,
1048
+ BigInt .parse ("-3696164633313280000000000001" ).toDouble ());
1042
1049
}
1043
1050
1044
1051
main () {
You can’t perform that action at this time.
0 commit comments