Get the name of a number, even if it's stupidly big.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
此仓库已存档。您可以查看文件和克隆,但不能推送或创建工单/合并请求。

22 行
717 B

  1. import { Digit, GetKiloName } from '../../common'
  2. import NAMES from './names'
  3. import getKiloCombiningPrefix from './base/kilo/combiningPrefix'
  4. const getLongKiloName: 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 baseKiloName = getKiloCombiningPrefix(kiloHundreds, kiloTens, kiloOnes) + NAMES.kiloEvenSuffix
  16. return thousandPower % 2n === 0n ? baseKiloName : NAMES.thousand + ' ' + baseKiloName
  17. }
  18. export default getLongKiloName