Doing some calculations with doubles which then need to be cast to an int. So i have a quick question, when casting a double say 7.5 to an int, it will return 7.
Is this a product of rounding or just striping anything after the decimal point?
If it is a product of rounding, is it smart ie 0.1 to 0.5 it rounds down and 0.6 to 0.9 it rounds up?
Cheers
It does not round, it just returns the integral part before the decimal point.
Reference (thanks Rawling) Explicit Numeric Conversions Table:
You can try simple issues like this by yourself by writing simple tests. The following test (using NUnit) will pass and therefore give an answer to your question: