Hi,
A slightly different thing, apart from the exponent:
.000000056697
can be written
5.6697e-8
If that is a constant, you should declare it as such, then use the variable name:
1 2 3 4
|
const double TheConst = 5.6697e-8; // rename this variable to something meaningful - I don't know what it is, so I used this bad name instead
double TSquared = AvgSurfaceTemp* AvgSurfaceTemp // might come up with a better name than TSquared
double E = TheConst * TSquared * TSquared ;
|
That way you can avoid using "magic numbers" in your code. If the value of a variable might change, you change it in one place, rather than everywhere throughout your code.
Not sure why you are multiplying by 1
With
double
or
float
, I always write a digit before and after the decimal point, as in
1.0
,
0.1
not
1
or
.1
If you are using formulae from documentation (wiki say) then as comments, copy & paste the URL and the actual formula before the code.
Hope this helps a bit :+) And Good luck with your coding :+)
Edit:
C++11 has overloads for the
pow
function, so you could pass the exponent of 4 as an
int
Edit2:
I mention this because I suspect the compiler is smart enough to multiply when using an integer exponent instead of using a binomial series expansion.