该多项式的阶数由参数n传递过来。 3. 例 程
#include
main (void) {
double x,y;
double d[3] = {1.1,3.5,2.7}; x = 2.2;
y = eval_poly(x,d,2);
printf(\,x,y); }
4. 返回值 本函数返回一个双精度数,该数是自变量x对应的多项式值。18 EXP函数
1. 提 要
#include
#include
main (void) {
double f;
for(f = 0.0;f <= 5;f += 1.0)
printf(\,f,exp(f)); }
4. 参 阅 log( ),log10( ),pow( )
19 FABS函数
1. 提 要
#include
11
3. 例 程
#include
main (void) {
printf(\,fabs(1.5),fabs(-1.5)); }
4. 参 阅 abs( )
20 FLOOR函数
1. 提 要
#include
#include
main (void) {
printf(\,floor( 1.5 )); printf(\,floor( -1.5)); }
21 FREXP函数
1. 提 要
#include
double frexp (double f,int * p) 2. 描 述 frexp( )函数将一个浮点数分解成规格化小数和2的整数次幂两部分,整数幂部分存于指针 p 所指的 int 单元中。本函数的返回值x或在区间(0.5,1.0)内,或为 0;而且有
pf=x×2。如果f为0,则分解出来的两部分均为0。 3. 例 程
#include
main (void) {
12
double f; int i;
f = frexp(23456.34,&i);
printf(\,f,i); }
4. 参 阅 ldexp( )
22 GET_CAL_DATA函数
1. 提 要
#include
double get_cal_data (const unsigned char * code_ptr) 2. 描 述 本函数从PIC 14000标定空间返回一个32位的浮点标定数据。只有利用这个函数才能访问KREF、KBG、BHTHERM和KTC单元(32位浮点参数)。由于FOSC和TWDT均是一个字节长度,故可以直接访问它们。 3. 例 程
#include
main (void) {
double x;
unsigned char y;
x = get_cal_data(KREF);/*获得参考斜率(slope reference ratio)*/ y =TWDT;/*获得WDT溢出时间*/ }
4. 返回值 返回定标参数值。
注意:本函数仅用于PIC 14000
23 GMTIME函数
1. 提 要
#include
struct tm * gmtime (time_t * t) 2. 描 述 本函数把指针 t 所指的时间分解,并且存于结构体中,精确度为秒。其中,t 所指的时间必须自1970年1月1日0时0分0秒起。本函数所用的结构体被定义在time.h文件中,可参照本节“数据类型”部分。 3. 例 程
#include
13
void
main (void) {
time_t clock; struct tm * tp; time(&clock);
tp = gmtime(&clock);
printf(\n\\n\,tp->tm_year+1900); } 4. 参 阅 ctime( ),asctime( ),time( ),localtime( ) 5. 返回值 返回tm类型的结构体。
注意:由于编译器不会提供time( )程序,故它需要由用户给定。详情请参阅time( )函数。6. 数据类型
typedef long time_t; struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; };
24 ISALNUM,ISALPHA,ISDIGIT,ISLOWER 等函数
1. 提 要
#include
14
int isupper (char c) int isxdigit(char c) 2. 描 述 以上函数都被定义在ctype.h文件中。它们将测试给定的字符,看该字符是否为已知的几组字符中的成员。
isalnum (c) c在0~9、a~z或者A~Z范围内; isalpha (c) c在A~Z或a~z范围内; isascii (c) c为7位ASCII字符; iscntrl (c) c为控制字符; isdigit (c) c为十进制阿拉伯数字; islower (c) c在a~z范围内; isprint (c) c为打印字符; isgraph (c) c为非空格可打印字符; ispunct (c) c不是字母数字混合的; isspace (c) c是空格键、TAB键或换行符; isupper (c) c在A~Z范围内; isxdigit (c) c在0~9、a~f或A~F范围内。 3.例 程
#include
main (void) {
char buf[80]; int i;
gets(buf); i = 0;
while(isalnum(buf[i])) i++;
buf[i] = 0;
printf(\\\n\,buf); }
4.参 阅
toupper( ),tolower( ),toascii( )
25 KBHIT函数
1. 提 要
#include
15
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库PIC单片机的C语言应用下的函数库(3)在线全文阅读。
相关推荐: