-
Notifications
You must be signed in to change notification settings - Fork 27.5k
fix(numberFilter): properly format small number expressed with e notation #10252
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,6 +200,14 @@ describe('filters', function() { | |
expect(number(-1e-6, 6)).toEqual('-0.000001'); | ||
expect(number(-1e-7, 6)).toEqual('-0.000000'); | ||
}); | ||
|
||
it('should filter exponentially small numbers when no fraction specified', function() { | ||
expect(number(1e-10)).toEqual('0.000'); | ||
expect(number(0.0000000001)).toEqual('0.000'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if there is no fractional size, then we should have the minimum number of trailing zeros, this is it should equal There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lgalfaso this is not how it works for numbers like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
expect(number(-1e-10)).toEqual('0.000'); | ||
expect(number(-0.0000000001)).toEqual('0.000'); | ||
}); | ||
}); | ||
|
||
describe('json', function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not the right check, if
fractionSize
=== 0, then we do not wantpattern.maxFrac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lgalfaso can we ever go into this case? It could only happen for something like 1e-2 which would be converted to 0.01 anyway. So I think we are good here, unless I'm missing other bcases of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, there is a test that uses fractionSize 0 but then again, if you can think of a test that would fail with the current impl, then let's change things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of course
fractionSize
can be 0, it is an optional parameter, but that does not mean that0
is not a valid value