Calculate cubic root

4

I'm having trouble creating the following Cube root and LN buttons. I have buttons that should be very similar like for example the normal square root and the log.

I tried to create the following for the cube root:

   private void btn_raizcub_Click(object sender, RoutedEventArgs e)
    {
        primeiro += double.Parse(janela.Text);
        resutado = Convert.ToSingle(Math.Sqrt(primeiro/3.0));
        janela.Text = resutado.ToString();
    }
    
asked by anonymous 25.09.2016 / 20:08

1 answer

4

The correct formula for obtaining the cube root is:

Pow(primeiro, 1.0/3.0)

See running on dotNetFiddle .

Note that this double.Parse() may fail, I would not use it this way. It's kind of weird to create a double-precision type and use Convert.ToSingle() .

    
25.09.2016 / 20:40