Discover the answers you need at Westonci.ca, a dynamic Q&A platform where knowledge is shared freely by a community of experts. Our platform provides a seamless experience for finding precise answers from a network of experienced professionals. Explore comprehensive solutions to your questions from a wide range of professionals on our user-friendly platform.

What is the algorithm to determine the absolute of a number

Sagot :

This was written in python, let me know if it needs to be in another language.

View image trihext

Answer:

Conditionals are slower than plain arithmetic operations, but much, much faster than something as silly as calculating the square root

Explanation:

integer or bitwise op: 1 cycle floating -point add/ sub/mul: 4 cycles . Floating- point div ~ 30 cycles Floating - point exponentiation :~ 60 cycles depending on implementation Conditional branch : avg. 10_ cycles, better if well- predicted , much worse if mispredicted.

Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. We're here to help at Westonci.ca. Keep visiting for the best answers to your questions.