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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
09-25-2017, 02:27 AM
|
#1
|
Member
Registered: Oct 2008
Posts: 54
Rep:
|
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.
|
|
|
09-25-2017, 02:38 AM
|
#2
|
Member
Registered: Mar 2015
Distribution: Linux Mint
Posts: 634
|
What have you tried? What programming language are you considering?
|
|
|
09-25-2017, 02:40 AM
|
#3
|
LQ Addict
Registered: Dec 2013
Posts: 19,872
|
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, 03:15 AM
|
#4
|
Member
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997
|
|
|
|
09-25-2017, 05:21 AM
|
#5
|
Member
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 567
|
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.
|
|
|
09-25-2017, 10:54 AM
|
#6
|
Member
Registered: Sep 2011
Distribution: Puppy
Posts: 601
Rep:
|
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.
|
09-28-2017, 08:41 AM
|
#7
|
Member
Registered: Oct 2016
Distribution: Slackware
Posts: 310
Rep:
|
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.
|
|
|
09-28-2017, 08:39 PM
|
#8
|
Member
Registered: Jul 2004
Location: Chennai, India
Posts: 952
|
Till 19 they are unique; then they follow a regular pattern.
|
|
|
All times are GMT -5. The time now is 08:56 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|