I don't know what's wrong, but %d is for a decimal integer. For double, you should use %lf