-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Number utils #3467
Number utils #3467
Conversation
With regards to point-2, I am a bit confused if you are referring to floating-point precision, or if you are talking about allowing arbitrary precision.
And to illustrate the number vs string precision problem:
So overall it would be good if you elaborate a bit more on the design goals. |
@mwdchang I've address these comments and am focusing on formatting rather than parsing. Change made: |
}); | ||
}); | ||
|
||
describe('numberToNist', () => { |
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.
Need example here and nistToNumber
and displayNumber
for this rule
However, when there are only four digits before or after the decimal marker, we recommend that no space is required and no space should be used
For example:
1234.123
-> 1234.123
1234.1234
-> 1234.1234
11234.123
-> 11 234.123
1234.12344
-> 1 234.123 44
11234.123
-> 11 234.123
11234.1234
-> 11 234.123 4
import { exponentialToNumber, numberToNist, nistToNumber, displayNumber } from '@/utils/number'; | ||
|
||
describe('number util tests', () => { | ||
describe('exponentialToNumber', () => { |
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.
Probably should handle this number with thin spaces and exponentials
e.g. -1 234.567 89e+1
-> -1.234 567 89e+4
-> -12345.6789
Description
I have made the input for all these functions a string, since we can deal with very small or very large numbers it can lead to precision issues if we were to use the Number library to manipulate these inputs
UNIT TESTS!!