LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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: 53

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: 629

Rep: Reputation: 314Reputation: 314Reputation: 314Reputation: 314
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: 16,858
Blog Entries: 10

Rep: Reputation: 5013Reputation: 5013Reputation: 5013Reputation: 5013Reputation: 5013Reputation: 5013Reputation: 5013Reputation: 5013Reputation: 5013Reputation: 5013Reputation: 5013
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, 03:15 AM   #4
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 708

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

Rep: Reputation: 273Reputation: 273Reputation: 273
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: 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, 08:39 PM   #8
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 942

Rep: Reputation: 216Reputation: 216Reputation: 216
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 05:04 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
Open Source Consulting | Domain Registration