Differenze tra le versioni di "Pow()"

Da Gambas-it.org - Wikipedia.
Riga 5: Riga 5:
  
 
Volendola utilizzare direttamente in Gambas, bisognerà dichiararla con ''Extern'', nonché dichiarare la libreria ''Math'': ''libm.so'':
 
Volendola utilizzare direttamente in Gambas, bisognerà dichiararla con ''Extern'', nonché dichiarare la libreria ''Math'': ''libm.so'':
  Private <FONT color=#B22222>Extern pow</font>(x As Float, y As Float) As Float In "<FONT color=#B22222>libm</font>"
+
  Private <FONT color=#B22222>Extern pow</font>(x As Float, y As Float) As Float In "<FONT color=#B22222>libm:6</font>"
  
  
Riga 12: Riga 12:
 
  <FONT color=Gray>' ''double pow(double x, double y)''
 
  <FONT color=Gray>' ''double pow(double x, double y)''
 
  ' ''Return X to the Y power.''</font>
 
  ' ''Return X to the Y power.''</font>
  Private Extern <FONT color=#B22222>pow</font>(x As Float, y As Float) As Float In "<FONT color=#B22222>libm</font>"
+
  Private Extern <FONT color=#B22222>pow</font>(x As Float, y As Float) As Float In "<FONT color=#B22222>libm:6</font>"
 
   
 
   
 
   
 
   

Versione delle 14:24, 28 nov 2016

La funzione della libreria di Math

double pow(double x, double y);

ritorna x elevato alla potenza di y (ossia: xy ). Pertanto la funzione pow() effettua l'elevamento a potenza di un numero.


Volendola utilizzare direttamente in Gambas, bisognerà dichiararla con Extern, nonché dichiarare la libreria Math: libm.so:

Private Extern pow(x As Float, y As Float) As Float In "libm:6"


Semplice esempio di uso in Gambas:

' double pow(double x, double y)
' Return X to the Y power.
Private Extern pow(x As Float, y As Float) As Float In "libm:6"


Public Sub Main()

 Dim fl As Float

  fl = pow(2, 3)

  Print fl
 
End