Почитать книжку по С?
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено Yuriy 15 сентября 2003 г. 23:09
В ответ на: что за ерунда такая с этим HI-TECH PICC/ полные му....ки отправлено incognito 15 сентября 2003 г. 22:52

перемножаются два int: (int)255*(int)256.
в результате получается (int)(255*256), равный (int)(-256)
После чего эта величина преобразовывается в unsigned long.

Так что все правильно.

Со мной согласен iso9899-c99.pdf:

6.3.1.3 Signed and unsigned integers
1 When a value with integer type is converted to another integer type other than _Bool,if the value can be represented by the new type, it is unchanged.

2 Otherwise, if the new type is unsigned, the value is converted by repeatedly adding or subtracting one more than the maximum value that can be represented in the new type until the value is in the range of the new type. 49)

49)The rules describe arithmetic on the mathematical value, not the value of a given type of expression.


Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru