Processing math: 100%

Computer storage

Fixed-point number system

Fixed-point number system is a computer model for integers. One storage unit may be M=8/16/32/64 bit.

.Machine$integer.max
## [1] 2147483647
# integer type in R uses M=32 bits
M <- 32
big <- 2^(M-1) - 1
small <- -2^(M-1)
as.integer(big)
## [1] 2147483647
as.integer(big + 1)
## Warning: NAs introduced by coercion to integer range
## [1] NA
as.integer(small + 1)
## [1] -2147483647
as.integer(small)
## Warning: NAs introduced by coercion to integer range
## [1] NA

Keep track of overflow and underflow. If the result of a summation is R, which must be in the set [2M1,2M11], there are only three possibilities for the true sum: R, R+2M (overflow), or R2M (underflow).

Floating-point number system

Floating-point number system is a computer model for real numbers.

2^((2^2 + 2^3 + 2^4 + 2^5 + 2^6) - 127) * (1 + 2^(-2))
## [1] 0.15625

To summarize