The following code is used to get the number of decimal places after the decimal point, but can go into an infinite loop sometimes on my compiler:
g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)

The...