LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   script to convert numbers in to string (https://www.linuxquestions.org/questions/linux-newbie-8/script-to-convert-numbers-in-to-string-4175614461/)

pankajd 09-25-2017 01:27 AM

script to convert numbers in to string
 
Hi,
Is there any script that would help me with conversion of number (digits) in to string (amount to be paid) in like in INR

e.g.

123456789.56

Twelve crore thirty four lacs fifty six thousand seven hundred and eighty nine rupees and fifty six paise

Thanks.

Sefyir 09-25-2017 01:38 AM

What have you tried? What programming language are you considering?

ondoho 09-25-2017 01:40 AM

sounds like how they used to count money in britain in the old days.
it's not that long ago, maybe you can find a conversion script and adapt it.

!!! 09-25-2017 02:15 AM

http://www.zyxware.com/articles/3516...mbering-system
https://stackoverflow.com/questions/...th-paise-value
https://stackoverflow.com/questions/...l-value-in-php
https://stackoverflow.com/questions/...-format-in-php
https://www.computing.net/answers/of...pes/11726.html
From this web-search: convert number to inr crore lakhs "linux"

aragorn2101 09-25-2017 04:21 AM

This can be easily done. But a script might not be the best way because the easiest way is to use division. The easiest method of doing this is to use some program in C or a small python routine.

e.g. algorithm

Code:

loop UNIT through {crore, lakh, 10000, 1000, 100, ...}
  divide number by UNIT
  if quotient is less than 1
    number cannot be expressed in terms of crores
    go to next UNIT
  else
    quotient is the number of crores
    remainder = number - (quotient x 1 crore)
    go to next UNIT


dave@burn-it.co.uk 09-25-2017 09:54 AM

That sounds like a standard HOMEWORK question from a programming course, that has been asked and answered MANY times before.

Fat_Elvis 09-28-2017 07:41 AM

Argh... is that pseudocode?

Eh... script in which language? This is doable in Bash, but as aragorn2101 has noted, easier in a language with solid math capabilities.

AnanthaP 09-28-2017 07:39 PM

Till 19 they are unique; then they follow a regular pattern.


All times are GMT -5. The time now is 02:19 PM.