sqrt(p1) public

Returns the non-negative square root of numeric.

0.upto(10) {|x|
  p [x, Math.sqrt(x), Math.sqrt(x)**2]
}
#=>
[0, 0.0, 0.0]
[1, 1.0, 1.0]
[2, 1.4142135623731, 2.0]
[3, 1.73205080756888, 3.0]
[4, 2.0, 4.0]
[5, 2.23606797749979, 5.0]
[6, 2.44948974278318, 6.0]
[7, 2.64575131106459, 7.0]
[8, 2.82842712474619, 8.0]
[9, 3.0, 9.0]
[10, 3.16227766016838, 10.0]
Show source
Register or log in to add new notes.