Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

decimal convert  to ASCII -need math formula

Posted on 2008-06-23
7
Medium Priority
?
2,127 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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever thought of installing a power system that generates solar electricity to power your house? Some may say yes, while others may tell me no. But have you noticed that people around you are now considering installing such systems in their …
Article by: Nicole
This is a research brief on the potential colonization of humans on Mars.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

670 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