Solved

decimal convert  to ASCII -need math formula

Posted on 2008-06-23
7
1,944 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 32

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! https://www.google.com/about/careers/students/guide-to-technical-development.html How to Know You are Making a Difference at EE In August, 2013, one …
This article provides a brief introduction to tissue engineering, the process by which organs can be grown artificially. It covers the problems with organ transplants, the tissue engineering process, and the current successes and problems of the tec…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

867 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

19 Experts available now in Live!

Get 1:1 Help Now