I'm debugging some C++ code, and have come across a double that never appears to have been given a value. It is declared with the line
double x;
Having not used C or C++ much before, I'm unsure whether doubles have a value that they default to? I.e. Given the declaration above, if x
is never specifically given a value, will it automatically be 0, or will it be null
?
The x
is used in a calculation elsewhere in the code, and the result of the calculation is meant to be displayed to the user - at the moment it's not... The calculation is:
y * asin(sin(x / y) * sin(a * b));
I would assume that if x
defaults to 0, this would cause a compile/runtime error? If x
defaults to 0, surely the calculation would return 0, and 0 would be displayed to the user?