السلام وعليكم
اخواني انا اتعلم من كتاب انجليزي في ++c كل شئ تمام
لكن هناك امر لم اعرفه مسالة Over و Under في هذا الموضوع
------------------------------------ الموضوع --------------------------------------------------
The program sets a short variable (sam) and an unsigned short variable (sue) to the
largest short value, which is 32,767 on our system.Then it adds 1 to each value.This
causes no problems for sue because the new value is still much less than the maximum
value for an unsigned integer. But sam goes from 32,767 to –32,768! Similarly, subtracting
1 from 0 creates no problems for sam, but it makes the unsigned variable sue go from 0 to
65,535.As you can see, these integers behave much like an odometer. If you go past the
limit, the values just start over at the other end of the range (see Figure 3.1). C++ guarantees
that unsigned types behave in this fashion. However, C++ doesn’t guarantee that
signed integer types can exceed their limits (overflow and underflow) without complaint,
but that is the most common behavior on current implementations.
صورة
http://www3.0zz0.com/2016/0...الكود
http://pastebin.com/AXGCjR6u
التعليقات