square-root

Why do most programming languages only give one answer to square root of 4?

Most programming languages give 2 as the answer to square root of 4. However, there are two answers: 2 and -2. Is there any particular reason, historical or otherwise, why only one answer is usually given? ...

Looking for an efficient integer square root algorithm for ARM Thumb2

I am looking for a fast, integer only algorithm to find the square root (integer part thereof) of an unsigned integer. The code must have excellent performance on ARM Thumb 2 processors. It could be assembly language or C code. Any hints welcome. ...

John Carmack's Unusual Fast Inverse Square Root (Quake III)

Hello, 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 constant. See the code below. Can someone explain line by line what exactly is going on here and why this works so much faster than the r...

Writing your own square root function.

How do you write your own function for finding the most accurate square root of an integer? After googling it, I found this, but firstly, I didn't get it completely, and secondly, it is approximate too. Assume square root as nearest integer (to the actual root) or a float. ...

How to do the square root in PowerPoint VBA?

Here is some math code that adds A to B: Sub math() A = 23 B = 2 ABSumTotal = A + B strMsg = "The answer is " & "$" & ABSumTotal & "." MsgBox strMsg End Sub But how can I calculate a square root of ABSumTotal? Is it possible in PowerPoint VBA? ...

Square root function in Forth using x86 Assembly?

I don't know much about assembly, but I am pretty sure that there are square root instructions on the x86? I am trying to get a square root function to work well in froth and the one that I have found gets bogged down somehow when I run it many times. : sqrt-closer ( square guess -- square guess adjustment) 2dup / over - 2 / ; : sqrt (...

Arrays- Square root of an Array and printing the result JAVA

Hello, The title says it all, really. I'm trying to get an array of (9) numbers square rooted then printed but I keep coming back with only one result - the number of numbers in the array squared- obviously not what I want. Thanks for any help. Ok, here is my terrible code so far. Trying to pass it to a method as well. public stat...

How do I compute the square root of a number without using builtins?

how can i create method which return sqrt of given nunber? for example sqrt(16) returns 4 and sqrt(5) returns 2.3... please help i am using java and know Math.sqrt() API function but i need method itself ...

Does a range of integers contain at least one perfect square?

Given two integers a and b, is there an efficient way to test whether there is another integer n such that a ≤ n2 < b? I do not need to know n, only whether at least one such n exists or not, so I hope to avoid computing square roots of any numbers in the interval. Although testing whether an individual integer is a perfect square is f...

square-root and square of vector doubles in C++

Hi, I'd like to calculate the square and square-root of a vector of doubles. For example given: vector<double> Array1(10,2.0); vector<double> Array2(10,2.0); for(unsigned int i=0; i<Array1.size(); i++) Array1[i] = sqrt(Array1[i]); for(unsigned int i=0; i<Array2.size(); i++) Array2[i] = Array2[i] * Array2[i]; Is the...

sqrt turn out to be 4.9999 , instead of 5

Possible Duplicate: Why do I see a double variable initialized to some value like 21.4 as 21.399999618530273? sqrt(25.0) turns out to be 4.99999 ,instead of 5 how would I fix this problem? ...

How is the square root function implemented?

How is the square root function implemented? ...

Binary Search to Compute Square root (Java)

I need help writing a program that uses binary search to recursively compute a square root (rounded down to the nearest integer) of an input non-negative integer. This is what I have so far: import java.util.Scanner; public class Sqrt { public static void main(String[] args) { Scanner console = new Scanner(System.in); Sys...