Get the name of a number, even if it's stupidly big.
25개 이상의 토픽을 선택하실 수 없습니다.
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
|
- import { GetKiloName } from '../../NumberSystem'
- import NAMES from './names.json'
- import getKiloCombiningPrefix from './base/kilo/combiningPrefix'
-
- const getLongKiloName: GetKiloName = (thousandPower) => {
- if (thousandPower === 0) {
- return ''
- }
- if (thousandPower === 1) {
- return NAMES.thousand
- }
- const kilo = thousandPower
- const kiloHundreds = Math.floor(kilo / 2 / 100)
- const kiloTens = Math.floor((kilo / 2 / 10) % 10)
- const kiloOnes = Math.floor((kilo / 2) % 10)
- const baseKiloName = getKiloCombiningPrefix(kiloHundreds, kiloTens, kiloOnes) + NAMES.kiloEvenSuffix
-
- return thousandPower % 2 === 0 ? baseKiloName : NAMES.thousand + ' ' + baseKiloName
- }
-
- export default getLongKiloName
|