We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 45a8b72 commit 30e8878Copy full SHA for 30e8878
lib/src/api/extensions.dart
@@ -52,12 +52,14 @@ extension RoundNum on num {
52
/// Step 3: round(12435678.9) = 12435679
53
/// Step 4: 12435679 / 1000 = 12435.679
54
double roundToPrecision(int decimal) {
55
+ if (isNaN || isInfinite) return toDouble();
56
final double precision = pow(10, decimal).toDouble();
57
return (this * precision).round() / precision;
58
}
59
60
/// Returns the double as a pretty rounded double.
61
num toPrettyPrecision(int precision) {
62
+ if (isNaN || isInfinite) return this;
63
_formatter.maximumFractionDigits = precision;
64
return num.parse(_formatter.format(this));
65
0 commit comments