Solved

decimal convert  to ASCII -need math formula

Posted on 2008-06-23
7
2,030 Views
Last Modified: 2012-06-21
How to convert decimal  to ASCII  -need math formula
0
Comment
Question by:al3457
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Article by: Nicole
This is a research brief on the potential colonization of humans on Mars.
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

710 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