I came across this code in some existing codebase:
double rad = ComputeCurviness();
double off = Math.Abs(rad);
if (rad < 0) off = -off;
It seems to be basically just making off
equal to rad
. The variables are used interchangeably later in the code. Is there any reason to leave this code in?
If rad
is -0.0, off
will be +0.0. You'd have to inspect the code to see whether this would actually make a difference. The two are equivalent when it comes to calculations and comparisons, but -0.0 is negative, which you can detect if you try hard enough.