Get the name of a number, even if it's stupidly big.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Deze repo is gearchiveerd. U kunt bestanden bekijken en het klonen, maar niet pushen of problemen/pull-requests openen.
|
- import { GetKiloName } from '../../NumberSystem'
- import NAMES from './names.json'
- import getKiloCombiningPrefix from './base/kilo/combiningPrefix'
-
- const getKiloName: GetKiloName = (thousandPower) => {
- if (thousandPower === 0) {
- return ''
- }
- if (thousandPower === 1) {
- return NAMES.thousand
- }
- const kilo = thousandPower - 1
- const kiloHundreds = Math.floor(kilo / 100)
- const kiloTens = Math.floor((kilo / 10) % 10)
- const kiloOnes = Math.floor(kilo % 10)
-
- return getKiloCombiningPrefix(kiloHundreds, kiloTens, kiloOnes) + NAMES.kiloEvenSuffix
- }
-
- export default getKiloName
|