Get the name of a number, even if it's stupidly big.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
To repozytorium jest zarchiwizowane. Możesz wyświetlać pliki i je sklonować, ale nie możesz do niego przepychać zmian lub otwierać zgłoszeń/Pull Requestów.

24 wiersze
761 B

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