[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

8-bit data type

Posted on 2000-01-24
5
Medium Priority
?
196 Views
Last Modified: 2012-08-14
I want to write a C programme for a 8-bit microprocessor. All the data type used in the program should be 8-bit. I know that char is also 8-bit, but i need to do some arithemic operation, so char may not be suitable. Which data type can i use which is 8-bit and can do some arithemic operation?
0
Comment
Question by:ckchan1
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:Ready4Dis
ID: 2383981
Why would a char not be suitable for arithemic operations?  C can use chars for math, just has a limit from -128 to 127.  This isn't a huge amount of space to work with, but can be used.  What kind of formulas need to be done, then I can try to help you use only 8-bits in the answer.
0
 
LVL 3

Accepted Solution

by:
ufolk123 earned 100 total points
ID: 2383997
Hi ckchan1,

I think char data type should be just fine.You can use a set of characters to emulate basic operations for large data lengths  easily.

You could Read

 Anthony Breitzman, "A Class for Representing Large Integers," C/C++ Users Journal, November 1996

for more information on this type of emulation.


ufolk123
0
 

Author Comment

by:ckchan1
ID: 2384036
i want to change a 32-bit addition to a 8-bit addition, since can't use 32 bit data type. I need to use 4 8-bit char to do the addition? is it something additional should be done? or just add it?
0
 

Author Comment

by:ckchan1
ID: 2387402
i want to change a 32-bit addition to a 8-bit addition, since can't use 32 bit data type. I need to use 4 8-bit char to do the addition? is it something additional should be done? or just add it?
0
 
LVL 3

Expert Comment

by:ufolk123
ID: 2387643
Hi ckchan1,

I think additions should be straightforward....

Say two numbers are  

x[4]  and  y[4]

then you need a loop like

carry=0;
for(int i=0;i<4;i++)
{
res[i]=(carry+x[i]+y[i])/10;
carry=(carry+x[i]+y[i])%10;
}

You can optimise it futher using bit map operations may be.
I am assuming both the numbers are +ve.

Like that you can device other arithmatic ops


Regards,
ufolk123

0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

591 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