Convert Number to Words in Indian currency format with paise value

Convert Number to Words in Indian currency format with paise value

  1. Blog
  2. 15 November 2026
  3. 5 min read

Stefan Bogdanescu

Founder & Senior Architect

Converting Numeric Values to Indian Currency Words with Paise in PHP

Converting a floating-point number into its verbal representation is a non-trivial task, especially when adhering to specific regional formatting rules like the Indian numbering system. The challenge compounds significantly when you need to handle decimal values (paise) precisely without rounding errors. In the context of your request—transforming 190908100.25 into "nineteen crores nine lakh eight thousand one hundred Rupees .two five Paise"—you are dealing with two distinct domains: large-scale number grouping and fractional currency representation.

The core requirement here is to avoid external libraries if possible, utilizing only the PHP language core. This implies implementing a custom logic engine that handles place value mapping, specifically for Crores and Lakhs, which differ from the standard Western thousands/hundreds model used in many other programming languages.

Parsing the Integer Component

To achieve the desired output for the integer part (190908100), you must first decompose the number based on Indian place values. The standard approach involves extracting chunks of digits corresponding to specific periods: Units, Thousands, Lakhs, and Crores.

A robust strategy is to use modulo arithmetic and integer division to isolate these chunks. For a number like 190908100:

  • Crores: Divide by 1,00,00,000 (10^8).
  • Lakhs: Take the remainder, divide by 1,00,000 (10^5).
  • Thousands: Take the remaining remainder, divide by 1,000 (10^3).
  • Units: The final remainder.

Once isolated, each chunk must be converted to words using a standard helper function that maps digits (0-9) and handles place values like "hundred", "thousand" (within the chunk), etc. Note that in Indian English, "lakh" is always singular when referring to the period unit, whereas "crore" follows similar grammatical rules depending on the count.

The critical distinction in your expected output is the handling of the decimal part. Standard currency conversion often rounds paise to the nearest integer or displays them as a fraction (e.g., "25 Paise"). However, your specification explicitly requests .two five, treating the decimal places individually regardless of their numerical value. This suggests a digit-by-digit extraction for the fractional part rather than a mathematical rounding operation.

Implementing Decimal Precision Without Rounding

In PHP, floating-point arithmetic can be notoriously unstable due to how IEEE 754 standards are handled. If you simply cast 190908100.25 to an integer or multiply by 100, you might encounter precision issues where 0.25 becomes 0.24999999 or similar artifacts in more complex calculations.

To strictly adhere to the .two five format without rounding logic, you should manipulate the string representation of the number directly after splitting at the decimal point.

$number = 190908100.25;

// Split into integer and fractional parts
if (strpos((string)$number, '.') !== false) {
    $integerPart = (int)explode('.', (string)$number)[0];
    $fractionalPart = substr((string)$number, strpos((string)$number, '.') + 1);
} else {
    $integerPart = (int)$number;
    $fractionalPart = '';
}

// Ensure fractional part does not exceed desired length or pad if necessary
// For strict .two five logic, we treat each digit after decimal individually
if ($fractionalPart === '') {
    $fractionalPart = '00'; // Or handle as per specific business rule
} else {
    // Limit to two digits for paise context usually, but logic depends on input
    // If input is .25, we want "two five"
    // If input is .1, should it be "one zero"? The prompt implies exact digit reading.
}

// Convert integer part using a custom place-value function
$integerWords = convertToWords($integerPart); 

// Convert fractional digits individually
$paiseWords = '';
for ($i = 0; $i < strlen($fractionalPart) && $i < 2; $i++) {
    $digit = (int)$fractionalPart[$i];
    if ($digit > 0) {
        $paiseWords .= numberToWords($digit) . ' ';
    }
}

// Final assembly
$result = trim($integerWords) . ' Rupees ' . trim($paiseWords) . ' Paise';

Handling the Place Value Logic

The convertToWords function is the most complex part. It requires a mapping array for digits 0-9 and logic to handle composite numbers (e.g., 15 becomes "fifteen", not "one five"). For the Indian system, you must inject "crore" and "lakh" at the appropriate indices during the decomposition phase.

A common pitfall is failing to handle zeros correctly within chunks. If a chunk is 05, it should be read as "five", not "zero five". Your logic for the integer part must strip leading zeros within the specific period before converting to words, except for the very first period which might require a zero if the number starts with it (though standard inputs usually don't).

Regarding the decimal handling, your example output .two five implies a literal reading of digits. If the input were 190908100.5, a strict digit reader would output ".five", but a currency formatter might expect ".five zero". Given the specific requirement in your source material, the implementation should likely iterate through the decimal string and convert each non-zero digit to its word equivalent, ignoring trailing zeros unless the business logic dictates otherwise.

Why Core PHP is Insufficient for Production Without Libraries

While core PHP allows you to build this functionality, it requires significant boilerplate code for number-to-text conversion. This increases maintenance overhead compared to using established libraries like php-money or specific localization packages that handle international currency formatting standards (ISO 4217).

However, if strict dependency minimization is a requirement, the custom function approach described above ensures no external dependencies are introduced. It is vital to remember that this manual conversion is case-sensitive and locale-dependent. The spelling of "Rupees" and "Paise" must match your regional standards exactly.

For enterprise applications requiring high reliability in financial reporting, consider wrapping this logic in a service class or leveraging Laravel's localization features if you are using the framework. If you are working within a Laravel project, you might explore community packages that extend Number formatting capabilities, but building the core engine yourself offers total control over the "two five" decimal behavior.

Ultimately, the trade-off here is between code complexity and format precision. The manual digit iteration for paise guarantees the exact output string you requested, bypassing any internal rounding logic that standard financial libraries might apply by default.

Our network