>Yes. Casting either of the multiplicands as you've shown will guarantee
>that the entire expression is evaluated as 64 bit integers.
>>Yes. Casting either of the multiplicands as you've shown will guarantee
>>that the entire expression is evaluated as 64 bit integers.
[quoted text clipped - 4 lines]
> width of intermediate values
> during expression evaluation?
In the standard, this is primarily governed by 5.9, which states that
expressions use promotions (widening, see 4.5) not conversions (narrowing,
see 4.7), but vendor-specific types such as __int64 are not mentioned.
> Jeff Bean
> Jeff Bean
> CWC Software
> Tel: (480) 596-9617
> Fax: (480) 443-0594
> Email: jeff@cwcsoftware.com
Doug Harrison [MVP] - 19 Sep 2007 01:33 GMT
>In the standard, this is primarily governed by 5.9, which states that
>expressions use promotions (widening, see 4.5) not conversions (narrowing,
>see 4.7)
Chapter 5, paragraph 9 talks about the "usual arithmetic conversions",
which can involve both promotion and conversion. Note that "conversions"
aren't strictly narrowing; for example, int-to-long is a conversion, not a
promotion. The term "promotion" means conversion of a (nominally) smaller
type to int, unless int can't hold all the values of the smaller type, in
which case, the conversion goes per 4.5.
> but vendor-specific types such as __int64 are not mentioned.
It's inconceivable that a compiler vendor would purposely do the unexpected
here and not extend the rules that govern built-in types to types such as
__int64. MSDN doesn't mention __int64 in the obvious places in the "Visual
C++ Language Reference", but that doesn't really bother me. I've always
"just used" the type, and it's always worked as expected.

Signature
Doug Harrison
Visual C++ MVP