This is a simple program designed to figure out how many significant digits are used for floating point. The idea is simple: Pick a nice repeating fraction such 1/3 (0.333333), print it, and see how many digits you get.
However, the results puzzled this programmer. He knew the computer couldn't be that stupid. So what happened?
1 /************************************************
2 * divide -- Program to figure out how many *
3 * digits are printed in floating point *
4 * by print 1/3 or 0.333333. *
5 ************************************************/
6 #include <iostream>
7
8 int main()
9 {
10 float result; // Result of the divide
11
12 result = 1/3; // Assign result something
13
14 std::cout << "Result is " << result << '\n';
15 return (0);
16 }