square-root

square root character/symbol

人走茶凉 提交于 2019-11-28 05:19:33
问题 I was wondering what the character code of the square root symbol is in java? That is, I want to be able to print a square root sign on screen inside a string of other characters, or as the label on a button. 回答1: Take a look at the Unicode character charts at http://www.unicode.org/charts/ See also http://www.google.com/search?q=square+root+character - you might find what you're looking for as the very first hit... 回答2: I am sure it's \u221A . Try it out or try googling it, and you might end

How to improve fixed point square-root for small values

笑着哭i 提交于 2019-11-27 22:59:49
I am using Anthony Williams' fixed point library described in the Dr Dobb's article " Optimizing Math-Intensive Applications with Fixed-Point Arithmetic " to calculate the distance between two geographical points using the Rhumb Line method . This works well enough when the distance between the points is significant (greater than a few kilometers), but is very poor at smaller distances. The worst case being when the two points are equal or near equal, the result is a distance of 194 meters, while I need precision of at least 1 metre at distances >= 1 metre. By comparison with a double

How to implement the “fast inverse square root” in Java?

℡╲_俬逩灬. 提交于 2019-11-27 21:24:22
I've heard of the "fast inverse square root", discussed here , and I wanted to put it in my Java program (just for research purposes, so ignore anything about the native libraries being faster). I was looking at the code, and the C code directly converts the float into an int with some C pointer magic. If you try to do this in Java with casts, it doesn't work: java truncates the float (as you would expect), and you can't get the pointer of a primitive (as you can in C). So how do you do this? Riking Remember to benchmark your code before using this. If it turns out you don't need it, or it's

How does the computer calculate Square roots? [closed]

情到浓时终转凉″ 提交于 2019-11-27 15:42:09
问题 How does the computer calculate Square roots ? I mean what is going on there! How does it process it!! Does it use some mathematical ways like Newton's method? What about Trigonometric Functions? And almost all those Mathematical Functions . In the case that every language has its own way, then please let's talk about c++. 回答1: Most modern non-embedded CPUs (x86 and the larger ARM cores, for example) have hardware instructions to compute square roots directly. The hardware implementation

Trouble with float on C [duplicate]

筅森魡賤 提交于 2019-11-27 05:42:31
This question already has an answer here: C program to convert Fahrenheit to Celsius always prints zero 8 answers I have this little program in C that calculates the square root x of a positive integer N using a recursive function (implemented using a while loop). If I calculate x using this: x = (1/2)*(x + N/x) //x0 = 1.0 Then x keeps growing to inf and then nan. However if I use this: x = (x + N/x)/2 //x0 = 1.0 It works fine, why? Thanks. 1/2 does integer division, its result is 0 , change either or both operand to double , e.g: 1.0/2 来源: https://stackoverflow.com/questions/26643536/trouble

How can I find the Square Root of a Java BigInteger?

↘锁芯ラ 提交于 2019-11-27 00:53:31
Is there a library that will find the square root of a BigInteger? I want it computed offline - only once, and not inside any loop. So even computationally expensive solution is okay. I don't want to find some algorithm and implement. A readily available solution will be perfect. Just for fun: public static BigInteger sqrt(BigInteger x) { BigInteger div = BigInteger.ZERO.setBit(x.bitLength()/2); BigInteger div2 = div; // Loop until we hit the same value twice in a row, or wind // up alternating. for(;;) { BigInteger y = div.add(x.divide(div)).shiftRight(1); if (y.equals(div) || y.equals(div2))

How to improve fixed point square-root for small values

隐身守侯 提交于 2019-11-26 21:20:03
问题 I am using Anthony Williams' fixed point library described in the Dr Dobb's article " Optimizing Math-Intensive Applications with Fixed-Point Arithmetic " to calculate the distance between two geographical points using the Rhumb Line method. This works well enough when the distance between the points is significant (greater than a few kilometers), but is very poor at smaller distances. The worst case being when the two points are equal or near equal, the result is a distance of 194 meters,

How to implement the “fast inverse square root” in Java?

戏子无情 提交于 2019-11-26 20:56:48
问题 I've heard of the "fast inverse square root", discussed here, and I wanted to put it in my Java program (just for research purposes, so ignore anything about the native libraries being faster). I was looking at the code, and the C code directly converts the float into an int with some C pointer magic. If you try to do this in Java with casts, it doesn't work: java truncates the float (as you would expect), and you can't get the pointer of a primitive (as you can in C). So how do you do this?

How is the square root function implemented?

三世轮回 提交于 2019-11-26 19:43:08
How is the square root function implemented? Srujan Kumar Gulla Source here (Babylonian method) . Problem statement: Given x>0, find y such that y^2=x => y=x/y (this is the key step). Guess some value g for y and test it. Compute x / g. If x / g is close enough to g, return g. Otherwise, try a better guess. double test(double x, double g) { if closeEnough(x/g, g) return g; else return test(x, betterGuess(x, g)); } boolean closeEnough(double a, double b) { return (Math.abs(a - b) < .001); } double betterGuess(double x, double g) { return ((g + x/g) / 2); } sqrt(2) | Guess g x / g | New guess,

How can I find the Square Root of a Java BigInteger?

我与影子孤独终老i 提交于 2019-11-26 17:27:59
问题 Is there a library that will find the square root of a BigInteger? I want it computed offline - only once, and not inside any loop. So even computationally expensive solution is okay. I don't want to find some algorithm and implement. A readily available solution will be perfect. 回答1: Just for fun: public static BigInteger sqrt(BigInteger x) { BigInteger div = BigInteger.ZERO.setBit(x.bitLength()/2); BigInteger div2 = div; // Loop until we hit the same value twice in a row, or wind // up