# Thread: C++: is there a function more faster than sqrt()?

1. ## C++: is there a function more faster than sqrt()?

C++: is there a function more faster than sqrt()?
i did several searchs and i found some.. but some don't give me some results and others are slow 2. Square root calculations are never cheap. You could enable fast math for your compiler which breaks IEEE compliance though. E.g. it will be assumed that everything is finite.
Another question worth to ask is why does it even make such a big difference for you how fast sqrt() is? We don't know your code. So we can't judge whether there's an opportunity to reduce the number of sqrt() calls. Some times it is possible to just do all the operations with the square values and calculate the root only once at the end. 3. 16 clock cycles isn't fast enough? 4. Originally Posted by flp1969 16 clock cycles isn't fast enough?
When they do dumb stuff like trying to draw each pixel with a new thread, then they'd find a way to make an infinite machine run slowly.
how use multithread inside a class? - C++ Forum 5. Originally Posted by joaquim C++: is there a function more faster than sqrt()?
i did several searchs and i found some.. but some don't give me some results and others are slow
Not sure if this would help in your particular case, but sometimes it is practical to "redo the maths" of your program to process the squares instead. I used that very approach in a low-level circle-drawing routine I implemented some years back. First I stored the square of the circle radius in a variable. Then, as I looped through a grid of candidate pixels, I only needed to compare x*x + y*y with the precomputed radius_squared. I did need a sqrt() call for certain edge cases (I needed sub-pixel accuracy there) but regardless the entire routine ran much much faster than before. Popular pages Recent additions faster, function, give, results, sqrt 