The problem is that you're using %d to print a float instead of %f.