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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
|
- import { Digit, GetKiloName } from '../../common'
- import NAMES from './names'
- import getKiloCombiningPrefix from './base/kilo/combiningPrefix'
-
- const getEuropeanLongKiloName: GetKiloName = (thousandPower) => {
- if (thousandPower === 0n) {
- return ''
- }
- if (thousandPower === 1n) {
- return NAMES.thousand
- }
- const kilo = thousandPower
- const kiloHundreds = kilo / 2n / 100n
- const kiloTens = (Number(kilo / 2n / 10n) % 10) as Digit
- const kiloOnes = (Number(kilo / 2n) % 10) as Digit
- const kiloCombiningPrefix = getKiloCombiningPrefix(kiloHundreds, kiloTens, kiloOnes)
-
- return thousandPower % 2n === 0n
- ? kiloCombiningPrefix + NAMES.kiloEvenSuffix
- : kiloCombiningPrefix + NAMES.kiloOddSuffix
- }
-
- export default getEuropeanLongKiloName
|