Skip to main content

Posts

Showing posts with the label c

unsigned long long long long long int

Congratulations! You've encountered one of the more hair-brained stupid schemes of the past century. There is no way in ANSI C/C++ to say, "I want X bits of storage for this integer." Your initial thought might be, "Wait a minute, that can't be right...right?" Let us look at the various data types available to an ANSI C/C++ programmer: char int float double struct/class/template/union pointer A 'char' lets us declare a single byte. A byte is 8 bits...or is it? CHAR_BIT (in limits.h) is typically defined as 8 bits (and the Standard requires it to be defined as a _minimum_ of 8). However, it could be defined as 9 and there has been some hardware where it is defined as 32. Additionally, it is up to each compiler to decide whether just saying 'char' is signed or unsigned. Thankfully 'float' and 'double' use the IEEE floating point standard. Edit: Due to some response, I should clarify: Every compiler I have ever used (and I've...