Skip to the content

Hikidashi引き出し

Era dates (和暦) and kanji numerals both ways, the dictionary forms of a conjugated word, a reading shared out over its kanji, words pulled from pasted text, and how hard a sentence is to read.

Hikidashi (引き出し) is a drawer: each tool is pulled out when it is wanted. About the name

Contents

Reference · Kanji numerals

writeJapaneseNumberfunction

The number as Japanese writes it, in kanji.

Grouped by myriads, so each group is a number below 10,000 followed by its unit: 120,000,000 comes out 一億二千万 rather than as a run of digits. With formal, the figures that can be altered are written in their formal characters, as on a contract or a banknote: 壱万 for 一万, 弐千 for 二千.

Import it

import { writeJapaneseNumber } from "@johnmorrisdotca/hikidashi/numerals";

Also exported from: @johnmorrisdotca/hikidashi

Definition

function writeJapaneseNumber(value: number, options?: { formal?: boolean; }): string | null

Parameters

NameTypeDescription
valuenumber

A whole number from 0 to 9,007,199,254,740,991.

options (optional){ formal?: boolean; }

formal: true writes 壱, 弐, 参, 拾 and 零 for 一, 二, 三, 十 and 〇.

Returns

string | null

The number in kanji; null when it is out of range: negative, not a whole number, or past 9,007,199,254,740,991.

Examples

import { writeJapaneseNumber } from "@johnmorrisdotca/hikidashi/numerals";

console.log(writeJapaneseNumber(120_000_000), writeJapaneseNumber(2024), writeJapaneseNumber(10));
console.log(writeJapaneseNumber(12_000, { formal: true }), writeJapaneseNumber(-1), writeJapaneseNumber(1.5));
一億二千万 二千二十四 十
壱万弐千 null null

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hikidashi 1.1.0.