473,425 Members | 1,691 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,425 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 5718
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.
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.