Sfoglia il codice sorgente

Trim input, update TODO

The inputs are now trimmed before conversion.

The TODO items are updated for possible correct formats.
master
parent
commit
7a890bbeef
2 ha cambiato i file con 14 aggiunte e 1 eliminazioni
  1. +13
    -0
      TODO.md
  2. +1
    -1
      packages/core/src/utils/numeric.ts

+ 13
- 0
TODO.md Vedi File

@@ -9,3 +9,16 @@
- [X] Ordinals (e.g. `twentieth`, `first`, `two millionth`)
- [ ] Implement other `fractionType`s, implement `lazy` fractions, e.g. `0.05` => `zero point zero five`,
will implement `ratio` (`zero and five over one hundred`) and `part` (`zero and five hundredths`)
- [ ] Special names? (e.g. `googol` for `1e+100`)

Some inputs to consider:

1. `1/2` converts to `one half`. When only `lazy` is enabled, it converts to `one over two`.
2. `5/10` or `0.5` or `.5` (on en-US or en-PH) converts to `five tenths`. When `simplify` is `true`, it converts to
`one half`. When only `lazy` is enabled, it converts to `five over ten`.
3. `1e-2` converts to `one hundredth`. It follows by `one thousandth`, `one millionth`, `one billionth`, `one trillionth` etc.
4. `2/1e+2` converts to `two hundredths`. `2/2e+2` converts to `two two-hundredths`.
5. Should we enable `1e+(1e+100)` inputs? "googolplex"
1. Should we enable `1e+1/10`?
2. Should we enable `1e+1/1e+2`?
3. Should we enable `1e+(1e+1)/10`?

+ 1
- 1
packages/core/src/utils/numeric.ts Vedi File

@@ -20,7 +20,7 @@ export const normalizeNumeric = (x: Numeric): string => {
return x.toString(10);
case 'string':
// TODO assume not all strings follow a correct format
return x;
return x.trim();
// return new BigNumber(x).toString(10)
case 'object':
return x.toString(10);


Caricamento…
Annulla
Salva