Get the name of a number, even if it's stupidly big.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
Это архивный репозиторий. Вы можете его клонировать или просматривать файлы, но не вносить изменения или открывать задачи/запросы на слияние.

21 строка
597 B

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