I'd like to understand better why choose
Код: Выделить всё
intКод: Выделить всё
unsignedPersonally, I've never liked signed values unless there is a valid reason for them. e.g. count of items in an array, or length of a string, or size of memory block, etc., so often these things cannot possibly be negative. Such a value has no possible meaning. Why prefer
Код: Выделить всё
intI ask this because both Bjarne Stroustrup and Chandler Carruth gave the advice to prefer
Код: Выделить всё
intКод: Выделить всё
unsignedI can see the argument for using
Код: Выделить всё
intКод: Выделить всё
shortКод: Выделить всё
longКод: Выделить всё
intBut signed over unsigned has always annoyed me. Are signed values genuinely faster on typical modern CPU architectures? What makes them better?
Источник: https://stackoverflow.com/questions/187 ... igned-in-c
Мобильная версия