High order/low order problem 
Author Message
 High order/low order problem

I am having a problem converting a decimal number to a character so that both
the high order and low order are written to the file.

Here is what I have so far:

int someNumber;
someNumber = 1;
fprintf(fp, "%c", someNumber);

When this is printed to the file it just writes "01h" when I need it to write
"01 00h".  Any ideas how to ensure the high order is written?

I am using an Intel machine so the big indian and little indian are backwards
from other machines...  So what I need is to have 00 01h written instead of 01h
written...I think. 8-)



Fri, 17 Nov 1995 03:27:20 GMT  
 High order/low order problem

     What you want is the quotient (?) and the remainder (modulo) after
division by 256, thus:

        printf("%c%c", number / 256, number % 256);

                                                Daniel Chung
                                                I take followups and replies
                                                in Esperanto and English.



Sat, 18 Nov 1995 22:52:24 GMT  
 High order/low order problem
Quote:

>    printf("%c%c", number / 256, number % 256);

 Or even
        putchar (number >> 8);
        putchar (number & 255);
 which on most systems will be an order of magnitude faster.
--
# Bill Crawford aka *Cuddly_Cactus*  BSc (Hons) Computer Science Year Two #

# Any view that I express is not necessarily those of Brighton University #


Mon, 20 Nov 1995 18:48:24 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Writting low-order or high-order bytes

2. Separate low and high order ints

3. Newbie Question about high-order bit

4. High Order Bit

5. ** Getting the High Order Byte **

6. Warning: CFile::GetStatus() returns m_attribute without high-order flags

7. High-order bit etc

8. High-order word...

9. Q: how to check the high order bit?

10. Higher Order Functions?

11. GetAddressProc, Low and Hi-order words

12. CFile::GetStatus returns without high order flags

 

 
Powered by phpBB® Forum Software