Is there a difference between these two methods to convert a double to a negative value?

// Value is double

Is any difference? What is fast way for compiler to do this calculation?

value = System.Math.Abs(55.55);
this.Value = -value;

// or    
this.Value = System.Math.Abs(value) * (-1);
Jon Skeet
people
quotationmark

Is any diference?

Absolutely. Consider:

double value = -5;
this.Value = -value; // Sets Value to 5
this.Value = Math.Abs(value) * -1; // Sets Value to -5

Focus on correctness and simplicity before performance. What are you actually trying to achieve? How is that most simply expressed?

people

See more on this question at Stackoverflow