Skip to main content
Renesas India - Knowledgebase

Why I got an incorrect result by multiplying 32 bit by 32bit (long*long)

Latest Updated:09/10/2007


I got an incorrect result by multiplication 32 bit * 32bit (long*long). Why?


To handle the operation target value in long type, use a character of "L".

[For example]  

a = 0x000010ffL * 0x0000fff0L;
a = 0x000010ffL * 0x00001210L;

Or you can also cast the target using "long".

a = (long)0x000010ff * 0x0000fff0;
a = (long)0x000010ff * 0x00001210;

Suitable Products
C/C++ Compiler Package for SuperH Family
C/C++ Compiler Package for H8SX, H8S, H8 Family