cbrt

Math.cbrt(numeric) รข float
Class Public methods

Returns the cube root of numeric.

-9.upto(9) {|x|
  p [x, Math.cbrt(x), Math.cbrt(x)**3]
}
#=>
[-9, -2.0800838230519, -9.0]
[-8, -2.0, -8.0]
[-7, -1.91293118277239, -7.0]
[-6, -1.81712059283214, -6.0]
[-5, -1.7099759466767, -5.0]
[-4, -1.5874010519682, -4.0]
[-3, -1.44224957030741, -3.0]
[-2, -1.25992104989487, -2.0]
[-1, -1.0, -1.0]
[0, 0.0, 0.0]
[1, 1.0, 1.0]
[2, 1.25992104989487, 2.0]
[3, 1.44224957030741, 3.0]
[4, 1.5874010519682, 4.0]
[5, 1.7099759466767, 5.0]
[6, 1.81712059283214, 6.0]
[7, 1.91293118277239, 7.0]
[8, 2.0, 8.0]
[9, 2.0800838230519, 9.0]
doc_ruby_on_rails
2015-04-18 01:32:26
Comments
Leave a Comment

Please login to continue.