To write a computer program to print the first 1000 nonnegative powers of two, do you think you’d need to use arbitrary precision arithmetic? After all, 2^{1000} is a 302-digit number. How about printing the first 1000 negative powers of two? 2^{-1000} weighs in at a whopping 1000 decimal places. It turns out all you need is standard double-precision floating-point arithmetic — and the right compiler!

Continue reading “A Simple C Program That Prints 2,098 Powers of Two”