radice quadrata, sqrtf

Calcola la radice quadrata.

double sqrt(
   double x 
);
float sqrt(
   float x 
);  // C++ only
long double sqrt(
   long double x
);  // C++ only
float sqrtf(
   float x 
);

Parametri

  • x
    Valore in virgola mobile non negativo

Note

Il C++ consente di overload, gli utenti possono chiamare gli overload di sqrt che accettano float o i tipi appartiene lunghi.Nel programma c, sqrt sempre accetta e restituisce il doppio.

Valore restituito

La funzione di sqrt restituisce la radice quadrata di x.Se x è negativo, sqrt restituisce un non definito, per impostazione predefinita.

Input

Eccezione SEH

eccezione diMatherr

± QNAN, IND

nessuno

_DOMAIN

- ∞

NON VALIDO

_DOMAIN

x<0

NON VALIDO

_DOMAIN

Requisiti

Routine

Intestazione obbligatoria

sqrt, sqrtf

<math.h>

Per ulteriori informazioni sulla compatibilità, vedere Compatibilità nell'introduzione.

Esempio

// crt_sqrt.c
// This program calculates a square root.

#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main( void )
{
   double question = 45.35, answer;

   answer = sqrt( question );
   if( question < 0 )
      printf( "Error: sqrt returns %f\n", answer );
   else
      printf( "The square root of %.2f is %.2f\n", question, answer );
}
  

Equivalente .NET Framework

System::Math::Sqrt

Vedere anche

Riferimenti

Supporto per le operazioni in virgola mobile

exp, expf

log, logf, log10, log10f

della rimozione di pow, powf

_CIsqrt