Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

ascii converter

Status
Not open for further replies.

mulderm

Electrical
Jun 4, 2003
35
Hello,


I want to get a formula for basic so I can convert a Integer
word with 2 ascii sign to split them in a MSD and LSD.
Example:
I have received from a database PC a Integer word N7:0 = 8525.
These word have 2 ASCII words: MSD=! and LSD=M.
How is the formula for basic (1771-db) so that I can
split this integer word(8525) in MSD=33 (ascii=!) and
LSD=77 (ascii=M)?
Any ideas?

Greetings,

mulderm
 
Replies continue below

Recommended for you

Sure,

First divide 8525 into 256 (value of one byte) this will give you 33 i.e. ascii for "!". Then find out what the rest is by doing 8525 MOD 256 (it will give you the remainder) and get the result 77, which is ascii for "M".

The MOD function is sometimes found under the // symbol and then some. FORTH, for instance, uses /MOD for that function. You can, of course, also do 8525 - 33*256, which will do exactly the same thing.
 
The question is what do you want to do with the two ASCII
characters. If print, then it won't work-- it may translate into a control code, a non-printing character etc.
Each language processes ASCII text differently -- you must
know what you are doing.


<nbucska@pcperipherals.com>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor