Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Manipulate two 8-Bits using Carry?

Thread Tools

Manipulate two 8-Bits using Carry?

Bryan Parkoff
Posts: n/a
I break one U_WORD variable into two U_BYTE variables. I prefer to
manipulate two U_BYTE variables instead of one U_WORD variable using Carry.
Please look at my example using U_WORD variable below.

typedef unsigned char U_BYTE;
typedef unsigned short int U_WORD;

U_WORD HighLow = 0x00FE;
HighLow += 0x04;
U_BYTE Carry = HighLow >> 8;

It is not what I want to use this above. Please look at my example
using two U_BYTE variables below.

typedef unsigned char U_BYTE;

U_BYTE Low = 0xFE;
U_BYTE High = 0x00;
U_BYTE Carry = 0x00;
U_BYTE Temp = Low;
Low += 0x04;

if (Temp <= Low)
Carry = 0x00;
Carry = 0x01;
High += Carry;

My code above works fine. It is what I am using. It always use
unsigned when Low increases. If it wraps to 0, it sets Carry to increase
High. How can I write signed code? It has to tell Low to decrease using
signed. If it wraps to 0xFF, it sets Carry to decrease High. Low must
always use "+" to support unsigned and signed. For example below.

typedef unsigned short int U_WORD;
typedef signed short int S_WORD;

U_WORD HighLow = 0x0002;
HighLow += (S_WORD) 0xFC; // It shows 0xFFFE
U_BYTE Carry = (HighLow >> & 0x01; // It captures 0xFF to mask 0x01.

Can you please write two U_BYTE variables using signed in an example

Bryan Parkoff

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
using Find Control to manipulate individual rows in a datagrid.. HELp hudhu_handhu ASP .Net 0 02-19-2007 04:34 AM
Manipulate Crystal Reports file using java stand alone application Java 0 01-16-2007 07:15 AM
Good Book on Using Photoshop to Enhance(manipulate) photos Digital Photography 3 09-09-2006 01:26 AM
To manipulate or not to manipulate Dave C++ 1 01-22-2005 10:52 PM
how can I manipulate windows using Java? gino Java 3 07-14-2004 06:53 AM