LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 01:27 AM   #1
pankajd
Member
 
Registered: Oct 2008
Posts: 54

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, 01:38 AM   #2
Sefyir
Member
 
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
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
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
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 382Reputation: 382Reputation: 382Reputation: 382
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, 04:21 AM   #5
aragorn2101
Member
 
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

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 04:22 AM.
 
Old 09-25-2017, 09: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, 07: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, 07:39 PM   #8
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

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


Reply



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

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

All times are GMT -5. The time now is 06:01 AM.

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