Reputation: 31
I'm doing a bit of modding to a popular game (Minecraft) and I seen these lines in the terrain generation,
double d4 = 1.0D;
d4 *= d4;
d4 *= d4;
d4 = 1.0D - d4;
double d5 = (noise1[l1] + 256D) / 512D;
d5 *= d4;
I was wondering what the point of d4
was, because on the fourth line it would always be 0, wouldn't it?
Upvotes: 3
Views: 853
Reputation: 1500515
Yes, in straight Java at least this would be guaranteed to be 0.
For all the inaccuracies of floating binary point arithmetic, 1.0 itself can be represented exactly, and the result of multiplying it by itself will always get back to simply 1.0.
Are you sure there's nothing else going on elsewhere to make it slightly different to 1.0d? Or perhaps it was historically some value other than 0.1?
Upvotes: 5