Categories
Blog

Interesting discovery about Math.Abs

Math.Abs is more than twice slower than conditional negation? This is mysterious!

Screenshot 2014-07-08 05.20.36

I used the example code found on the Microsoft MSDN page to time the operations, and found that using Math.Abs is more than twice slower than conditional negation! Unfortunately I have no idea about the under-the-hood going-ons. Maybe some day I will do some digging to find out.

Anyway, attached below is the testing code.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.