Looking for an efficient integer square root algorithm for ARM Thumb2

Integer Square Roots by Jack W. Crenshaw could be useful as another reference. The C Snippets Archive also has an integer square root implementation. This one goes beyond just the integer result, and calculates extra fractional (fixed-point) bits of the answer. (Update: unfortunately, the C snippets archive is now defunct. The link points to the … Read more

Square root of BigDecimal in Java

I’ve used this and it works quite well. Here’s an example of how the algorithm works at a high level. Edit: I was curious to see just how accurate this was as defined below. Here is the sqrt(2) from an official source: (first 200 digits) 1.41421356237309504880168872420969807856967187537694807317667973799073247846210703885038753432764157273501384623091229702492483605585073721264412149709993583141322266592750559275579995050115278206057147 and here it is using the approach I outline … Read more

Program that solves a simple math equation [closed]

See also the ScriptEngine. import java.awt.*; import java.awt.event.*; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; import javax.swing.*; class EvaluateString { public static void main(String[] args) { Runnable r = new Runnable() { @Override public void run() { JPanel gui = new JPanel(new BorderLayout(5,5)); final JTextField input = new JTextField( “Math.pow(2.6,22)+ Math.pow(3.9,15)”,19); final JTextField output = new … Read more

Square root of number python

Use the math module instead of the cmath module; the latter is for complex numbers only: >>> import math >>> print math.sqrt(25) 5.0 For what it’s worth, the cmath result is correct, if you expected a complex number. You could take just the .real component of the result, but since there is a regular floating … Read more