Class: HumanNumber::NumberSystem::IndianSystem

Inherits:
DefaultSystem show all
Defined in:
lib/human_number/number_system.rb

Overview

Note:

Unlike Western and East Asian systems, the Indian system uses a mixed base progression that doesn't follow strict powers of 10 or 1000, reflecting the unique linguistic structure.

Indian subcontinent number formatting system using traditional South Asian units.

This system implements the traditional Indian number formatting convention using the progression: thousand (1,000), lakh (100,000), crore (10,000,000). This aligns with how large numbers are conceptualized and spoken in Hindi, Urdu, Bengali, and Indian English contexts.

The system follows a mixed base progression: thousands up to lakh, then lakhs up to crore, maintaining the linguistic patterns familiar to speakers of Indian subcontinent languages.

Examples:

Formatting examples

# Indian English
HumanNumber.human_number(123_456, locale: :'en-IN')  #=> "1 lakh 23K 456"
HumanNumber.human_number(12_345_678, locale: :'en-IN') #=> "1 crore 23 lakh 45K 678"

# Hindi/Urdu/Bengali contexts
HumanNumber.human_number(100_000, locale: :hi)       #=> "1 lakh"
HumanNumber.human_number(10_000_000, locale: :ur)    #=> "1 crore"

# Abbreviated mode
HumanNumber.human_number(12_345_678, locale: :'en-IN', max_digits: 2) #=> "1.2 crore"

Supported locales and currencies

# Locales: [:hi, :ur, :bn, :'en-IN']
# Currencies: ['INR']

Unit progression

# 1,000 = 1 thousand
# 100,000 = 1 lakh (not "100 thousand")
# 10,000,000 = 1 crore (not "10 million")

See Also:

Since:

  • 0.1.10

Constant Summary collapse

UNIT_DEFINITIONS =

Since:

  • 0.1.10

[
  { key: :crore, divisor: 10_000_000 },
  { key: :lakh, divisor: 100_000 },
  { key: :thousand, divisor: 1_000 },
].freeze

Method Summary

Methods inherited from DefaultSystem

format_below_min_unit, format_in_abbreviated_mode, format_in_complete_mode, format_number