New course! Every coder should learn Generative AI!
Try a free lesson0
A simple example:
double d = 1/2;
d is now 0
Why? 1 and 2 are Integer, therefore Integer division is executed which results in 0
Fix the problem:
double d = (double)1/2
This way d is 0.5
As the first operand is double, a double division is executed.