Pedro Izecksohn wrote: > --- "Tyler Littlefield" wrote: >> and you want... what exactly? > > I did not express myself well. > > Let me reformulate my question: > > --- "Paul Herring" wrote: >> Here you're multiplying two shorts. > > What is the type of result of a multiplication of two unsigned short > integers? > > In other words: > > Being: > > unsigned short int a, b; > T result; > //... > result = (a*b); > > What should be the type T? > > When running my previous code the result is: > Why fffffffffffe0001 != fffe0001 ? > > Is this result a compiler's bug?
No. You are looking at it wrong. Typecasting says that you know more than the compiler. Nowhere are you typecasting to a signed value. The compiler is treating the resulting value as an unsigned integer because that is exactly what you told it to do with typecasting. Finding a compiler-level bug is fairly difficult, rare, and, these days, typically involves some odd/advanced aspect of C++. C compilers are generally stable, so you are even less likely to find a bug there. BTW, you should have your compiler warnings turned up so that you get a warning for assigning a signed value to an unsigned variable. -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* MyTaskFocus 1.1 Get on task. Stay on task. http://www.CubicleSoft.com/MyTaskFocus/
