LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 09-25-2017, 02:27 AM   #1
pankajd
Member
 
Registered: Oct 2008
Posts: 51

Rep: Reputation: 15
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.
 
Old 09-25-2017, 02:38 AM   #2
Sefyir
Member
 
Registered: Mar 2015
Distribution: Linux Mint
Posts: 607

Rep: Reputation: 301Reputation: 301Reputation: 301Reputation: 301
What have you tried? What programming language are you considering?
 
Old 09-25-2017, 02:40 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 13,422
Blog Entries: 9

Rep: Reputation: 3668Reputation: 3668Reputation: 3668Reputation: 3668Reputation: 3668Reputation: 3668Reputation: 3668Reputation: 3668Reputation: 3668Reputation: 3668Reputation: 3668
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, 05:21 AM   #5
aragorn2101
Member
 
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 552

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

Last edited by aragorn2101; 09-25-2017 at 05:22 AM.
 
Old 09-25-2017, 10:54 AM   #6
dave@burn-it.co.uk
Member
 
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, 08:41 AM   #7
Fat_Elvis
Member
 
Registered: Oct 2016
Distribution: FreeDOS 1.2
Posts: 252

Rep: Reputation: 73
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, 08:39 PM   #8
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 900

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


Reply


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 09:59 AM
Nice script to convert numbers between bases (bin/dec/oct/hex) hgate73 Linux - General 4 02-17-2009 04:51 AM
how to convert a string of numbers to integer? cigarstub Programming 8 04-09-2007 08:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:48 PM.

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