in my application, i need operation of 16-bit * 16-bit
volatile dword mytempDword;
volatile word mytempword1 = 300;
volatile word mytempword2= 312;
main()
{
...
mytempDword = mytempword1 * mytempword2;
}
Codewarriror gives wrong result of 28064, but the correct result is 93600, i found that 93600 = 65536 + 28064 , obviously, the 16th bit is ignored by CodeWarrior. why? my setting options of CodeWarrior is default. and CodeWarriror version is 5.9
Anybody here know why? thanks
regards
Solved! Go to Solution.
Hi CaseyKevin,
A word can hold an unsigned number from 0 to 65535, or a signed number from -32768 to +32767.
The number 93600 would require at least 17 bits.
If you cast the words into dwords before you multiply, you should get the correct result.
Hi CaseyKevin,
A word can hold an unsigned number from 0 to 65535, or a signed number from -32768 to +32767.
The number 93600 would require at least 17 bits.
If you cast the words into dwords before you multiply, you should get the correct result.
follow you advices, i get the correct result
thanks very much