Get the name of a number, even if it's stupidly big.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
Este repositorio está archivado. Puede ver los archivos y clonarlo, pero no puede subir cambios o reportar incidencias ni pedir Pull Requests.

21 líneas
596 B

  1. import { GetKiloName } from '../../NumberSystem'
  2. import NAMES from './names.json'
  3. import getKiloCombiningPrefix from './base/kilo/combiningPrefix'
  4. const getKiloName: GetKiloName = (thousandPower) => {
  5. if (thousandPower === 0) {
  6. return ''
  7. }
  8. if (thousandPower === 1) {
  9. return NAMES.thousand
  10. }
  11. const kilo = thousandPower - 1
  12. const kiloHundreds = Math.floor(kilo / 100)
  13. const kiloTens = Math.floor((kilo / 10) % 10)
  14. const kiloOnes = Math.floor(kilo % 10)
  15. return getKiloCombiningPrefix(kiloHundreds, kiloTens, kiloOnes) + NAMES.kiloEvenSuffix
  16. }
  17. export default getKiloName