Posts tagged numbers
Since you often need them, but even more often than that forget about them again, here's a list:
2^4 16 2^8 256 2^16 65536 2^32 4294967296 2^64 18446744073709551616 2^128 340282366920938463463374607431768211456
all up to 32 bit
There exist quite some number formats, and how these are represented may differ in different programming languages. This post will try to create a condensed overview on the basics.
A bit consists of 8 bits in memory.
The number type called
byte uses one byte in memory for representation.
Which is a combination of 1's and 0's, a digits altogether.
So the possible numbers that can be represented are 2^8 = 256. That is, a byte can encode numbers from 0 to 255.
(This could differ depending on the implementation of the used platform, but except for very old or exotic systems one bit is always consisting of eight bits.)
unsigned vs. signed
unsigned means the number domain is lacking an algebraic sign,
signed does have one.
This will decide the actually possible numbers.
unsigned byte goes from 0 to 255.
signed byte goes from -128 to 127.
The signed ones use bit seven for representing the sign.
0 is for '+', 1 ist for '-'.
byte uses one exactly one byte in memory. If numbers bigger than 0 to 255 are needed, integers (read: ints) are uses. These use several bytes in memory for representation.
Usually formats with two, four and eight bytes are used, corresponding to 16, 32 and 64 bits. Also (depending on implementation, of course), these can be signed or unsigned.
On the amount of representable numbers:
Each time the bit/byte count is doubled, the maximum number is the new byte count is the square of the one with half the byte count.
Usually an unsigned int is the long name for uint.
Another convention is this naming scheme: (used in most programming languages)
16 bit =
32 bit =
64 bit =
Depending on the order of the bytes in memory used for representing a multi-byte value, either a big-endian-order or little-endian-order is in place. Here this means, if the bit on the lowest memory address houses the byte containing the lowest bits of the number, the little endian format is used.
On the intel architecture (and thus on all x86 and x64 systems), endianness is always little-endian.
MIPS, SPARC, PowerPC and Motorola's 68000 systems endianness is big-endian.
In case you need decimals, then there are
double coming to your rescue.
float's are single-precision, doubles are... double-precision.
This posting is not yet finished and will be expanded in the future.
View posts from 2017-02, 2017-01, 2016-12, 2016-11, 2016-10, 2016-09, 2016-08, 2016-07, 2016-06, 2016-05, 2016-04, 2016-03, 2016-02, 2016-01, 2015-12, 2015-11, 2015-10, 2015-09, 2015-08, 2015-07, 2015-06, 2015-05, 2015-04, 2015-03, 2015-02, 2015-01, 2014-12, 2014-11, 2014-10, 2014-09, 2014-08, 2014-07, 2014-06, 2014-05, 2014-04, 2014-03, 2014-01, 2013-12, 2013-11, 2013-10