Click here to Skip to main content
15,913,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Question[SOLVED]Sliding effect for text in MFC Pin
atrok13-Nov-07 21:41
atrok13-Nov-07 21:41 
AnswerRe: Sliding effect for text in MFC Pin
chandu00413-Nov-07 22:08
chandu00413-Nov-07 22:08 
AnswerRe: Sliding effect for text in MFC Pin
Cedric Moonen13-Nov-07 22:16
Cedric Moonen13-Nov-07 22:16 
QuestionData Conversion Byte to Integer Pin
quantimizer13-Nov-07 21:31
quantimizer13-Nov-07 21:31 
AnswerRe: Data Conversion Byte to Integer Pin
Peter Weyzen13-Nov-07 21:54
Peter Weyzen13-Nov-07 21:54 
QuestionRe: Data Conversion Byte to Integer Pin
David Crow14-Nov-07 3:35
David Crow14-Nov-07 3:35 
AnswerRe: Data Conversion Byte to Integer Pin
Peter Weyzen14-Nov-07 10:14
Peter Weyzen14-Nov-07 10:14 
AnswerRe: Data Conversion Byte to Integer Pin
CPallini13-Nov-07 22:19
mveCPallini13-Nov-07 22:19 
IMHO the above statement is clear:
values are stored inside the file as two bytes integers, with most significative byte first, for instance 1000 (that is 03E8h in hexadecimal notation) is stored as follows:
first byte = 3 (03h); second byte = 232 (E8h)

that is:
3 * 256 + 232 = 768 + 232 = 1000</code>.


On the other hand, negative numbers are stored using Sign and magnitude representation (see [^]), hence -1000 will become 83E8h in hexadecimal notation ( 8h=1000binary, i.e. sign bit ON).

Whenever you need to retrieve values you have to always check the sign bit. I give a C code snippet (error checking is left as an exercise to the reader...Smile | :) ):

unsigned char a,b;
int value;

/* read first byte */
fread(&a, sizeof(a), 1, fd);
/* read second byte */
fread(&b, sizeof(b), 1, fd);
/* get magnitude, i.e. absolute value */
value = ((a & 0x7F) << 8 ) | b;
/* check sign */
if ( a & 0x80)
{
  value = -value;
}
/* now value contains the (possibly negative?!? :-D) employee's salary!*/


Hope that helps
Smile | :)





If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

GeneralRe: Data Conversion Byte to Integer Pin
quantimizer14-Nov-07 1:26
quantimizer14-Nov-07 1:26 
GeneralRe: Data Conversion Byte to Integer Pin
CPallini14-Nov-07 1:35
mveCPallini14-Nov-07 1:35 
QuestionProblem with CPU Usage Pin
ashishbhatt13-Nov-07 21:26
ashishbhatt13-Nov-07 21:26 
GeneralRe: Problem with CPU Usage Pin
ashishbhatt13-Nov-07 21:58
ashishbhatt13-Nov-07 21:58 
GeneralRe: Problem with CPU Usage Pin
Peter Weyzen13-Nov-07 22:01
Peter Weyzen13-Nov-07 22:01 
GeneralRe: Problem with CPU Usage Pin
ThatsAlok13-Nov-07 23:25
ThatsAlok13-Nov-07 23:25 
GeneralRe: Problem with CPU Usage Pin
ashishbhatt13-Nov-07 23:41
ashishbhatt13-Nov-07 23:41 
GeneralRe: Problem with CPU Usage Pin
ashishbhatt13-Nov-07 23:38
ashishbhatt13-Nov-07 23:38 
GeneralRe: Problem with CPU Usage Pin
Cedric Moonen14-Nov-07 0:01
Cedric Moonen14-Nov-07 0:01 
GeneralRe: Problem with CPU Usage Pin
Cedric Moonen13-Nov-07 22:21
Cedric Moonen13-Nov-07 22:21 
AnswerRe: Problem with CPU Usage Pin
Peter Weyzen13-Nov-07 21:59
Peter Weyzen13-Nov-07 21:59 
QuestionMemory usage Pin
g_sandipan13-Nov-07 20:50
g_sandipan13-Nov-07 20:50 
AnswerRe: Memory usage Pin
only coder13-Nov-07 21:00
only coder13-Nov-07 21:00 
GeneralRe: Memory usage Pin
g_sandipan13-Nov-07 23:00
g_sandipan13-Nov-07 23:00 
AnswerRe: Memory usage Pin
Roger Stoltz14-Nov-07 0:47
Roger Stoltz14-Nov-07 0:47 
QuestionNeed help with array in C [modified] Pin
ndtoan1313-Nov-07 20:49
ndtoan1313-Nov-07 20:49 
AnswerRe: Need help with array in C Pin
Leslie Sanford13-Nov-07 21:26
Leslie Sanford13-Nov-07 21:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.