This is for a homework assignment about floats and doubles, we are to add 1/1 + 1/2 + 1/3 ... up to 1/10,000,000 and to do it again from 1/10,000,000 back down to 1/1 and to print both answers as doubles and floats. I had no problems with this but both the floats were different numbers with the 1/1 starting float being vastly different and both doubles being the same. I'm just wondering why this is the case and could find little relevant information.
double
is much more precise thanfloat
. Read more about it here.