B
Bryan Parkoff
I tell C++ Compiler to use level 4 warning instead of level 3 warning so
all variables can be calculated accuracy with no prone error.
It will give you a warning like this.
unsigned short A = 0x8002;
unsigned short B = 0x7FFF;
unsigned short C = 0;
C = A + B; // Warning loss high byte conversion -- 0x8002 + 0x7FFF = 0x10002
In fact, A and B are 16 Bits. They go into 32 Bits register to complete
the calculation before they go back to 16 Bits variable in memory Is it the
best practice to add unsigned short () between variable like this below.
C = unsigned short (A + B); // No Warning
It is like AND to mask only 16 Bits out of 32 Bits. Please advise if
there is a better practice to deal with level 4 warning.
Bryan Parkoff
all variables can be calculated accuracy with no prone error.
It will give you a warning like this.
unsigned short A = 0x8002;
unsigned short B = 0x7FFF;
unsigned short C = 0;
C = A + B; // Warning loss high byte conversion -- 0x8002 + 0x7FFF = 0x10002
In fact, A and B are 16 Bits. They go into 32 Bits register to complete
the calculation before they go back to 16 Bits variable in memory Is it the
best practice to add unsigned short () between variable like this below.
C = unsigned short (A + B); // No Warning
It is like AND to mask only 16 Bits out of 32 Bits. Please advise if
there is a better practice to deal with level 4 warning.
Bryan Parkoff