473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to convert numerical currency value (33,163.33) into words?

84
Hi there;

Is there anybody out there knows how to design a function or data flow on how to convert a numerical currency valu (33,163.33) into words
33Million one hundred sixty three thousand point thirty three.

Thanx
Jul 2 '07 #1
1 5717
Hi there;

Is there anybody out there knows how to design a function or data flow on how to convert a numerical currency valu (33,163.33) into words
33Million one hundred sixty three thousand point thirty three.

Thanx
First of all, wouldn't that be thrity three thousand, one hundred and sixty three point thirty three?

And to do that, you would basically need to make a function that would check how many digits were infront of the decimal point, and then based on that, determine what each number's word equivalent would be, and then do the same for after the decimal point.

it would be rather long and complex, and I'm not entirely sure on all of the details. You can take everything before the decimal by using the <cmath> function floor(double) to get an integer result.

This is what I have so far, I would suggest using a switch to determine which words to create, and I'm not sure how to isolate the decimal part of the number, but once that is done you can work with it similarly to the left part of the number.

Expand|Select|Wrap|Line Numbers
  1. string convertToWords(double value)
  2. {
  3.     int left = floor(value);
  4.     int temp;
  5.     int section = 1;
  6.  
  7.     string words = “”;
  8.     string part;
  9.  
  10.     while (left > 0)
  11.     {
  12.         temp = left % 1000;
  13.         left = left / 1000;
  14.  
  15.         //convert temp into words of blank hundred, blankty blank
  16.         //store this part of the words in the string part;
  17.         //use int section to determine if it’s the millions, thousands, etc.
  18.  
  19.         words = part + words;
  20.         section = section + 1;
  21.     }
  22. }
Jul 2 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Per Erik Stendahl | last post by:
Hi, I wish I could write large integers (and floats, etc) like this in Python: 10 000 000 Kind of the same way I can write string literals today. (As in 'This' 'is' 'one' 'string'.)
3
by: D | last post by:
Does anyone have a VBA code that converts numbers to Spelled out numbers? Example 100 to One Hundred. I need it for a check writing program and I don't feel like reinventing the wheel. Thanks
0
by: R. John Reed | last post by:
Hi All, I'm am looking to convert a currency string (e.g. "$1,234.56" to a double value). It appears this will work: double val = Convert.ToDouble(Double.Parse­("$123,456.78901",...
2
by: KB | last post by:
Hi guys, In my DataGrid I have a column that displays decimal values as currency ( I set the Data Formatting expression of that column to {0:C}). So the actual string displayed in the grid looks...
1
by: Vishal | last post by:
Hello, how can we convert a value from one currency to another currency in vb.net? Is that possible? I dont want to use any hardcoded value for the exchange rate. I wont to get it online and do...
2
by: Chakravarthy | last post by:
Given an XML stream as below, is there any possibility to convert the same into any treditional class style with . (dots) as seperator of the nodes of the xml file... for instance ...
52
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
9
by: ballygowanboy | last post by:
ok, so i've my front end shop code almost working, the quantity and price all add up........ now i need to add a curency conversion function, euro (default), dollar, and uk pound. right, i'm not...
2
vivek kushwaha
by: vivek kushwaha | last post by:
Hi guys, I need codes to convert Currency into Words. e.g. 120,500 into "One Lac. Five hundred only." in asp.net with vb.net 1.1. Please if anybody know about it. Reply me. Vivek.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.