轉到內容

一點點 C 教程/C 數學庫

來自維基文庫,為開放世界提供開放書籍

本章討論一些有用的標準 C 庫

  • 數學庫
  • 標準實用程式庫
  • "sprintf()" 函式
  • 字串函式庫
  • 字元類測試庫

以及以下次要主題

  • 命令列引數
  • 動態記憶體分配
  • 指向函式的指標
  • PC 記憶體模型和其他宣告
  • 故障排除提示

數學庫需要宣告

   #include <math.h>

數學函式包括

   sin( x )       Sine of x.
   cos( x )       Cosine of x.
   tan( x )       Tangent of x.
   asin( x )      Inverse sine of x.
   acos( x )      Inverse cosine of x.
   atan( x )      Inverse tangent of x.
   sinh( x )      Hyperbolic sine of x.
   cosh( x )      Hyperbolic cosine of x.
   tanh( x )      Hyperbolic tangent of x.
   exp( x )       Exponential function -- e^x.
   log( x )       Natural log of x.
   log10( x )     Base 10 log of x.
   pow( x, y )    Power function -- x^y.
   sqrt( x )      Square root of x.
   ceil( x )      Smallest integer not less than x, returned as double.
   floor( x )     Greatest integer not greater than x, returned as double.
   fabs( x )      Absolute value of x.

所有值都是“雙精度”,三角值以弧度表示。

華夏公益教科書