Aracılığıyla paylaş


sqrt, sqrtf

Kare kökünü hesaplar.

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

Parametreler

  • x
    Kayan nokta değeri negatif olmayan

Notlar

Because C++ allows overloading, you can call overloads of sqrt that take float or long double types.Bir C programında sqrt her zaman alan ve döndüren double.

Dönüş Değeri

sqrt İşlevler kare kökünü döndürür x.Varsayılan olarak, varsa x negatif sqrt belirsiz bir NaN döndürür.

Giriş

SEH özel durumu

_matherrÖzel durum

± QNAN, ONRAKİNİ BUL

yok

_DOMAIN

- ∞

yok

_DOMAIN

x < 0

yok

_DOMAIN

Gereksinimler

İşlev

C üstbilgisi

C++ üstbilgisi

sqrt, sqrtf, sqrtl

< math.h >

<cmath>

Uyumluluk bilgileri için bkz Uyumluluk.

Örnek

// 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 );
}
  

.NET Framework Eşdeğeri

System::Math::Sqrt

Ayrıca bkz.

Başvuru

Kayan Nokta Desteği

exp, expf

log, logf, log10, log10f

pow, powf, powl

_CIsqrt