At the risk of this going way out of the scope of this group, I think there is some 
vagueness in the C++ standard in regards to this.  According to the C++ standard (4.1):
"C++ follows ANSI C in defining integral promotions as 'value-preserving.'"
It doesn't specifically call out the * operator as being an operator that initiates 
promotion.  However, I would think that the term 'value-preserving' could mean 
(depending on the implementation) that the result of two unsigned short values would 
be promoted to an unsigned long.
Sorry if I've muddied the waters here.

-Jon

--------------------------------------------
Jonathan Hays
Palm OS Certified Developer
GE Infrastructure
http://hazelware.luggle.com
--------------------------------------------


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of DongDong
Sent: Wednesday, March 31, 2004 8:26 AM
To: Palm Developer Forum
Subject: Re: CW compiler Data type


If both aiRows and aiColumns are UInt16, the result will be UInt16.
It is necessary to typecast your statement if larger type is expected, like:

UInt32 qqq;
qqq = (UInt32) aiRows*aiColumns*4;

In fact, it give type to first argument only but the result will be UInt32
finally.
It is also a problem I experienced before.

"wax wacky" <[EMAIL PROTECTED]> ??? news:[EMAIL PROTECTED]
???...
>
> I am confused by the behaviour of my code warrior ..... my problem is
>
> in my program i have an assignment
>
> UInt32 qqq;
> qqq = (aiRows * aiColumns * 4); ///aiRows = 160, aiCloumns = 140 ;
>
> Now the problem : after execution qqq gets a value of 24064 (binary : 0101
1110 0000 0000 ) instead of 89600 (binary: 1 0101 1110 0000 0000)
>
> That means the operation (aiRows * aiColumns * 4) is giving only a 16 bit
value.
>
> PLEASE tell me is there a problem with my tool?.... is there some setting
which i have to set before using CW.
>
> PLEASE help me to find out the reason for such unusual behaviour....
> thanks
>
> wax
> -- 
> ______________________________________________
> IndiaInfo Mail - the free e-mail service with a difference!
www.indiainfo.com
> Check out our value-added Premium features, such as an extra 20MB for mail
storage, POP3, e-mail forwarding, and ads-free mailboxes!
>
> Powered by Outblaze
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to