Why does multiplying a double by -1 not give the negative of the current answer
- by Ankur
I am trying to multiply a double value by -1 to get the negative value. It continues to give me a positive value
double man = Double.parseDouble(mantissa);
double exp;
if(sign.equals("plus")){
exp = Double.parseDouble(exponent);
}
else {
exp = Double.parseDouble(exponent);
exp = exp*-1;
}
System.out.println(man+" - "+sign+" - "+exp);
The printed result is
13.93 - minus - 2.0
which is correct except that 2.0 should be -2.0