Update
This commit is contained in:
parent
3bef179616
commit
561ddf8822
20 changed files with 309 additions and 19 deletions
19
sqrt.md
Normal file
19
sqrt.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Square Root
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
|
||||
The following is an [approximation](approximation.md) of integer square root in [C](c.md) that has acceptable accuracy to about 1 million (maximum error from 1000 to 1000000 is about 7%): { Painstakingly made by me. ~drummyfish }
|
||||
|
||||
```
|
||||
int32_t sqrtApprox(int32_t x)
|
||||
{
|
||||
return
|
||||
(x < 1024) ?
|
||||
(-2400 / (x + 120) + x / 64 + 20) :
|
||||
((x < 93580) ?
|
||||
(-1000000 / (x + 8000) + x / 512 + 142) :
|
||||
(-75000000 / (x + 160000) + x / 2048 + 565));
|
||||
}
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue