Skip to content

Commit c572be5

Browse files
committed
docs: add scientific notation jsdoc
1 parent 28738b9 commit c572be5

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/numberUtil.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ type ParsedScientificNotation = {
6767
negative: boolean;
6868
};
6969

70+
/**
71+
* Parse a scientific-notation string into reusable parts.
72+
*
73+
* The idea is to split the value into mantissa and exponent first, then
74+
* normalize the mantissa into sign, integer/decimal segments, and a compact
75+
* digit sequence so later logic can move the decimal point without re-parsing.
76+
*/
7077
function parseScientificNotation(numStr: string): ParsedScientificNotation {
7178
const [mantissa, exponent = '0'] = numStr.toLowerCase().split('e');
7279
const negative = mantissa.startsWith('-');
@@ -83,6 +90,13 @@ function parseScientificNotation(numStr: string): ParsedScientificNotation {
8390
};
8491
}
8592

93+
/**
94+
* Expand parsed scientific notation into a plain decimal string.
95+
*
96+
* The core idea is to calculate where the decimal point lands after applying
97+
* the exponent, then rebuild the string by either padding zeros or inserting
98+
* the decimal point inside the normalized digit sequence.
99+
*/
86100
function expandScientificNotation(parsed: ParsedScientificNotation) {
87101
const { decimal, digits, exponent, integer, negative } = parsed;
88102

0 commit comments

Comments
 (0)