Hello.
I have written the next code lines:
typedef unsigned short uint16;
uint16* Pointer;
*Pointer = (uint16)((0x123456*20136)/0x169AF3);
This calculation should have resulted in 0x3F57,
But the code has reached somehow 0xFB66.
The type uint16 can hold 16 bits (4 hexadecimal digits), so I dont understand why there was a miscalculation here.
How should I perform this calculation in order for it to reach the correct result?
Thank you.
If its important, I'm working with IAR compiler.
I have written the next code lines:
typedef unsigned short uint16;
uint16* Pointer;
*Pointer = (uint16)((0x123456*20136)/0x169AF3);
This calculation should have resulted in 0x3F57,
But the code has reached somehow 0xFB66.
The type uint16 can hold 16 bits (4 hexadecimal digits), so I dont understand why there was a miscalculation here.
How should I perform this calculation in order for it to reach the correct result?
Thank you.
If its important, I'm working with IAR compiler.
Last edited: