Solved

decimal convert  to ASCII -need math formula

Posted on 2008-06-23
7
1,928 Views
Last Modified: 2012-06-21
How to convert decimal  to ASCII  -need math formula
0
Comment
Question by:al3457
7 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 21846612
Depends what you mean. If you mean that you want to convert the decimal digits 0, 1, ..., 9 to their ASCII values, then you simply need to add 0x30 (or 48 in decimal) to it.

So, the character '0' has ASCII value 48, '1' is 49, etc. ... until '9' which has 57 as ASCII value.
0
 
LVL 31

Expert Comment

by:awking00
ID: 21847232
Your question is a little vague. How do you intend to use this "conversion" formula?
0
 
LVL 27

Accepted Solution

by:
tliotta earned 500 total points
ID: 21848884
al3457:

Normally, I would expect that this question involves a network-transport such as FTP where the "decimal" value is a packed-decimal field. The transport function has sent records from the file. The file has EBCDIC encoding on the sending side and ASCII on the receiving side. The transport then applies EBCDIC-to-ASCII translation on the entire record as a single string; this causes packed-decimal fields to be improperly translated as characters rather than as the half-bytes (nibbles) that make up the "BCD" portion of EBCDIC.

Under those circumstances, the ASCII translation to 'fix' the fields must take into account the particular conversion tables that were used in the network transport. A straight character conversion will not work.

So, the question requires some added clarification.

Please describe the circumstances. What platform will be running the conversion? Is this running on an ASCII or EBCDIC system? What does the data look like -- is it records in a file? fields in records in a file? single values passed in as parms? What languages are to be used?

Perhaps most importantly, is it really a conversion that's needed? Or would it be better to fix the problem that caused packed-decimal values to arrive on an ASCII system?

Tom
0
 

Author Comment

by:al3457
ID: 21868907
Thank you Tom,
You got it.It is ASCII
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 21968406
Hi al3457,

Are you aware that FTPing from the AS/400 or using ODBC, is automatically converting fields from EBCDIC-to-ASCII, no conversion needed.
Just a remark :)

Regards,
Murph,
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction On a scale of 1 to 10, how would you rate our Product? Many of us have answered that question time and time again. But only a few of us have had the pleasure of receiving a stack of the filled out surveys and being asked to do somethi…
How to Win a Jar of Candy Corn: A Scientific Approach! I love mathematics. If you love mathematics also, you may enjoy this tip on how to use math to win your own jar of candy corn and to impress your friends. As I said, I love math, but I gu…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now