Please consider the following code:
unsigned int var1 = 4294967295;
unsigned int var2 = 1000000;
unsigned int var3;
var3 = some_expression - (var1*var2)/some_expression;
Bug:
In the expression for var3, the value:
(var1*var2) is being truncated to a 32-bit Integer (since it is obtained by multiplying 2 32-bit Integers).
Possible Fix:
var3 = some_expression - ((unsigned long int)var1*var2)/some_expression;
Problem:
Solaris does NOT accept this typecasting & throws the following error:
"conversion to non-scalar type requested"
Can I fix this issue without typecasting?
some_expression, so show us your real code.var1/someExpression*var2does not give the same answer asvar1*var2/someExpression, because integer division truncates.2*100/5is 40 exactly, but computing it as2/5*100gives 0.unsigned long, as you apparently incorrectly believe. It maps to some struct type, as I already noted in my answer.