Replaced "float" for "double" in several places.
scanf use now %lg instead of %g