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.
|
- 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
|