Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-25-2017, 01:27 AM   #1
Registered: Oct 2008
Posts: 53

Rep: Reputation: 15
script to convert numbers in to string

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



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

Old 09-25-2017, 01:38 AM   #2
Registered: Mar 2015
Distribution: Linux Mint
Posts: 634

Rep: Reputation: 316Reputation: 316Reputation: 316Reputation: 316
What have you tried? What programming language are you considering?
Old 09-25-2017, 01:40 AM   #3
LQ Addict
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051
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.
Old 09-25-2017, 02:15 AM   #4
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
From this web-search: convert number to inr crore lakhs "linux"
Old 09-25-2017, 04:21 AM   #5
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 567

Rep: Reputation: 301Reputation: 301Reputation: 301Reputation: 301
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

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
    quotient is the number of crores
    remainder = number - (quotient x 1 crore)
    go to next UNIT

Last edited by aragorn2101; 09-25-2017 at 04:22 AM.
Old 09-25-2017, 09:54 AM   #6
Registered: Sep 2011
Distribution: Puppy
Posts: 601

Rep: Reputation: 172Reputation: 172
That sounds like a standard HOMEWORK question from a programming course, that has been asked and answered MANY times before.
2 members found this post helpful.
Old 09-28-2017, 07:41 AM   #7
Registered: Oct 2016
Distribution: FreeDOS 1.2
Posts: 309

Rep: Reputation: 92
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.
Old 09-28-2017, 07:39 PM   #8
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
Till 19 they are unique; then they follow a regular pattern.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script to find the sum of numbers associated with each character in a string Aagam Linux - Newbie 22 02-07-2012 08:59 AM
Nice script to convert numbers between bases (bin/dec/oct/hex) hgate73 Linux - General 4 02-17-2009 03:51 AM
how to convert a string of numbers to integer? cigarstub Programming 8 04-09-2007 07:49 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:02 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration