
What's the fastest way to square a number in JavaScript?
function squareIt(number) { return Math.pow(number,2); } function squareIt(number) { return number * number; } Or some other method that I don't know about. I'm not looking for a golfed …
How do I calculate square root in Python? - Stack Overflow
Jan 20, 2022 · The power operator (**) or the built-in pow() function can also be used to calculate a square root. Mathematically speaking, the square root of a equals a to the power of 1/2. The …
Have I implemented the Square function correctly? - Stack Overflow
Jul 29, 2018 · I decided to write a simple program to square a number using functions. I get the desired output, however I would like to know if I have implemented it correctly?
python - Check if a number is a perfect square - Stack Overflow
How could I check if a number is a perfect square? Speed is of no concern, for now, just working. See also: Integer square root in python.
python - Squaring all elements in a list - Stack Overflow
I am told to Write a function, square(a), that takes an array, a, of numbers and returns an array containing each of the values of a squared. At first, I had def square(a): for i in a: prin...
c - Any way to obtain square root of a number without using …
Mar 13, 2015 · Here's an implementation of square root function using Newton-Raphson method. The basic idea is that if y is an overestimate to the square root of a non-negative real number …
Square of a number being defined using #define - Stack Overflow
Sep 15, 2010 · Still a very iffy #define as it evaluates x twice, so square(somefun()) calls the function twice and does not therefore necessarily compute a square but rather the product of …
What is more efficient? Using pow to square or just multiply it with ...
What is more efficient? Using pow to square or just multiply it with itself? Asked 15 years, 7 months ago Modified 4 years, 6 months ago Viewed 159k times
John Carmack's Unusual Fast Inverse Square Root (Quake III)
John Carmack has a special function in the Quake III source code which calculates the inverse square root of a float, 4x faster than regular (float)(1.0/sqrt(x)), including a strange 0x5f3759df …
Making a square() function without x*x in C++ - Stack Overflow
Mar 23, 2016 · Implement square () without using the multiplication operator; that is, do the x*x by repeated addition (start a variable result at 0 and add x to it x times). Then run some version of …