Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using towords() function to convert amount to words
value=6400

towards(value,0)

i am getting output like "six thousand four hundred "

but i want with decimal also

if value goes like this 6400.75 then i neeed

"six thousand four hundred and seventy paise"
Posted

1 solution

HI,

try like below.
Towords(truncate(6400.75), 0) + " Rupees and " + towords(abs(100 * (truncate(6400.75)- 6400.75)), 0) + "Paise";

result is: six thousand four hundred Rupees and seventy five paise

The first part i.e.
Towords(truncate(6400.75), 0) 

returns 6400, and will ignore the decimal place.

Second part i.e.
(abs(100 * (6400.75 - truncate(6400.75))

converts it to a positive value and multiplies the value to be non decimal.

If you have more decimal places you'll have to adjust the 100 multiplier.

hope it helps.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900