Operator Precedence - Macromedia Flash MX 1002004 Game Programming [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Macromedia Flash MX 1002004 Game Programming [Electronic resources] - نسخه متنی

Craig S. Murray, Justin Everett-Church

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید


















Operator Precedence



As you have just seen, several operators can be strung together into one statement. But as you can also see, the order in which they are evaluated is not simply left to right. That is because of operator precedence, which refers to the order in which operators are evaluated when more than one appears in the same statement. As you might have gathered from the previous example, the multiplication operator has a higher precedence than the addition operator. That''s why, regardless of the order we type them in, the multiplication is always executed first. And in a similar way, the assignment operator has lower precedence than either multiplication or division. Therefore, the result is not assigned until all the other operators have been evaluated. If you want to force arithmetic operations into a certain order, you can use parentheses. The following example demonstrates the use of parentheses, although they should be familiar to you from algebra:







result1 = (2 + 2) * 2;



As you might expect, the parentheses force the addition to execute first. The result of that addition is then multiplied by 2. Finally, a result of 8 is assigned to the variable result1.



Table 2.1 lists all the operators in Flash from highest to lowest precedence.



/ 43