+ 1
Float vs. Double?
What's the difference between a float and double interger? Are they interchangeable and if not should I always use a certain one?
5 Respuestas
+ 1
do a test - define float, double and decimal. and then use them as a place to store something like 10 / 3 or pi and see how much precision you need
0
double is more precise. floats are still precise, and in game dev terms, if you blow up the barrel and it flies for 100m - player won't care I'd landing is 2 cm off the actual point.
double is more precise, but then there is decimal.
0
So float would be 10.5 and double 10.58? Would the code be bugged if I put float for the double linterger?
0
I'd say stick to doubles for your testing needs. it doesn't matter, until it matters. check stack overflow discussion for full theory.
0
@Robert. Why when I tried these on code playground...
float x=10/3;
double y=10/3;
console.writeline("float = {0}. double = {1}", x, y);
the result both are 3....?