I'm writing a program that translates code written in another programming language into C.
I've found out that I can optimize the outputted code in this way:
Code:
long a, b, c, d, e;
a = b * c + d * e
Thing is, what if b * c is a positive value that doesn't fit in a long, and d * e is a negative value, that when added with b * c produces a value that fits in a long (ie it produces valid output). On Intel processors b * c would "wrap", and when I then add d * e to it, it would "wrap back", producing the same output as if I had written a = (long) ((float) b * (float) c + (float) d * (float) e). But I don't know how processors of other brands would react to this. Would they produce the same output?
Regards, Alexander Toresson