ruby - Why is `27 ** (1.0/3.0)` different from `27 ** (1/3)`? -


please let me know if correct way cubic root.

i can't understand why

27 ** (1.0/3.0) #=> 3  

is different from

27 ** (1/3) #=> 1 

1.0 / 3.0 # => 0.3333333333333333 27 ** 0.333 # => 2.9967059728946346  1 / 3 # => 0 27 ** 0 # => 1 

the second example of integer division. how many threes there in one? zero. number in power 0 1.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -