Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   EasyC Assignment rules (http://www.chiefdelphi.com/forums/showthread.php?t=62416)

jonboy 24-01-2008 13:19

EasyC Assignment rules
 
Question is where can I get the assignment rules when using mixed types in an assignment expression. Does ANSI C apply? TNX

whytheheckme 24-01-2008 13:22

Re: EasyC Assignment rules
 
Can you please explain a little bit further as to what you are referencing, and perhaps what you are trying to do?

We'd love to help! Just need more info.

Jacob

Alan Anderson 24-01-2008 16:45

Re: EasyC Assignment rules
 
The place where Microchip C diverges significantly from ANSI C is exactly what jonboy was asking about.

What you need to know is this: the compiler looks at the size of the operands when choosing the precision of the operator, and picks the smallest number of bits that will fit both operands. It doesn't care about the size of what you're storing the result in. If you're adding or multiplying two chars, the answer will be a char and overflow will be an issue. The typical workaround is to cast one of the operands as (int) in order to force the compiler to do 16-bit arithmetic instead of just 8.

jonboy 27-01-2008 11:07

Re: EasyC Assignment rules
 
Alan:

TNX for the reply. You hit the nail on the head. I was hoping the EasyC expert on the board would have the definitive answer. Not a big deal, but it would remove some of the mystery sooner and with greater ease.
TNX agn

Kingofl337 28-01-2008 16:36

Re: EasyC Assignment rules
 
If you are looking for the sizes open the help file click on "Index" and type/paste
"Variable definitions table"


All times are GMT -5. The time now is 23:17.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi