[Webinar] Streamline your web hosting managementRegister Today

x
Solved

# 8-bit data type

Posted on 2000-01-24
Medium Priority
196 Views
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
Question by:ckchan1
• 2
• 2

LVL 2

Expert Comment

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

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.

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

ufolk123
0

Author Comment

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

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

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

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
Course of the Month9 days, 11 hours left to enroll