I am programming in the c language on mac os x. I am using sqrt, from math.h, function like this:
int start = Data -> start_number;
double localSum;
for (start; start <= end; start++) {
localSum += sqrt(start);
}
This works, but why? and why am I getting no warning? On the man page for sqrt, it takes a double as parameter, but I give it an int – how can it work?
Thanks
Type conversions which do not cause a loss in precision might not throw warnings. They are cast implicitly.
What triggers a warning and what doesn’t is depends largely upon the compiler and the flags supplied to it, however, most compilers (atleast the ones I’ve used) don’t consider implicit type-conversions
dangerousenough to warrant a warning, as it is a feature in the language specification.To warn or not to warn:
C99 Rationale states it like a guideline
C99 Rationale (Apr 2003) : Page 45