- 浏览: 138032 次
- 性别:
- 来自: 杭州
最新评论
-
ziyuetian1943:
刚开始接触DB2 存储过程,在楼主这儿学习了
DB2存储过程总结 -
liubey:
我想问这个存储过程需要编译一下吗,也就是先执行一下,还是直接放 ...
在JAVA中调用DB2存储过程 -
新入职:
咦?竟然在2个月前留过言!
jQuery:基本教程 -
incredible:
good !
java中final与static关键字 -
jiangnan9399:
我现在正在学习JQery看了你的教程帮助很大,谢谢啦,
jQuery:基本教程
作用:将一个asii字符串转化为double类型的数据
头文件:stdlib.h
头文件:stdlib.h
/* Convert a string to a double. */ double atof (const char *nptr) { return strtod (nptr, (char **) NULL); }
#if HAVE_CONFIG_H # include <config.h> #endif #include <errno.h> #ifndef errno extern int errno; #endif #include <ctype.h> #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) # define IN_CTYPE_DOMAIN(c) 1 #else # define IN_CTYPE_DOMAIN(c) isascii(c) #endif #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c)) #define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c)) #define TOLOWER(c) (IN_CTYPE_DOMAIN (c) ? tolower(c) : (c)) #include <math.h> #include <float.h> #include <stdlib.h> #include <string.h> /* Convert NPTR to a double. If ENDPTR is not NULL, a pointer to the character after the last one used in the number is put in *ENDPTR. */ double strtod (const char *nptr, char **endptr) { register const char *s; short int sign; /* The number so far. */ double num; int got_dot; /* Found a decimal point. */ int got_digit; /* Seen any digits. */ /* The exponent of the number. */ long int exponent; if (nptr == NULL) /*如果为空串,则结束转换*/ { errno = EINVAL; goto noconv; /*转向处理无法转换的代码*/ } s = nptr; /* Eat whitespace. */ while (ISSPACE (*s)) ++s; /* Get the sign. */ sign = *s == '-' ? -1 : 1; if (*s == '-' || *s == '+') ++s; num = 0.0; got_dot = 0; got_digit = 0; exponent = 0; for (;; ++s) { if (ISDIGIT (*s)) { got_digit = 1; /* Make sure that multiplication by 10 will not overflow. */ if (num > DBL_MAX * 0.1) /* The value of the digit doesn't matter, since we have already gotten as many digits as can be represented in a `double'. This doesn't necessarily mean the result will overflow. The exponent may reduce it to within range. We just need to record that there was another digit so that we can multiply by 10 later. */ ++exponent; else num = (num * 10.0) + (*s - '0'); /* Keep track of the number of digits after the decimal point. If we just divided by 10 here, we would lose precision. */ if (got_dot) --exponent; } else if (!got_dot && *s == '.') /* Record that we have found the decimal point. */ got_dot = 1; else /* Any other character terminates the number. */ break; } if (!got_digit) goto noconv; if (TOLOWER (*s) == 'e') { /* Get the exponent specified after the `e' or `E'. */ int save = errno; char *end; long int exp; errno = 0; ++s; exp = strtol (s, &end, 10); if (errno == ERANGE) { /* The exponent overflowed a `long int'. It is probably a safe assumption that an exponent that cannot be represented by a `long int' exceeds the limits of a `double'. */ if (endptr != NULL) *endptr = end; if (exp < 0) goto underflow; else goto overflow; } else if (end == s) /* There was no exponent. Reset END to point to the 'e' or 'E', so *ENDPTR will be set there. */ end = (char *) s - 1; errno = save; s = end; exponent += exp; } if (endptr != NULL) *endptr = (char *) s; if (num == 0.0) return 0.0; /* Multiply NUM by 10 to the EXPONENT power, checking for overflow and underflow. */ if (exponent < 0) { if (num < DBL_MIN * pow (10.0, (double) -exponent)) goto underflow; } else if (exponent > 0) { if (num > DBL_MAX * pow (10.0, (double) -exponent)) goto overflow; } num *= pow (10.0, (double) exponent); return num * sign; overflow: /* Return an overflow error. */ errno = ERANGE; return HUGE_VAL * sign; underflow: /* Return an underflow error. */ if (endptr != NULL) *endptr = (char *) nptr; errno = ERANGE; return 0.0; noconv: /* There was no number. */ if (endptr != NULL) *endptr = (char *) nptr; return 0.0; }
发表评论
-
Struts2 namespace总结
2010-03-08 20:50 1735创建struts2的应用,首先 ... -
The Zen of Python
2009-12-26 23:46 877Abstract Long time Pythone ... -
权限控制
2009-10-28 09:23 814在系统权限控制中,要考虑资源功能是属于人,还是属于职位。观察这 ... -
javascript常用tools
2009-10-15 15:46 859//函数说明:求第y年第m月的天数 // ... -
javascript中 null 与 undefined的区别
2009-10-10 21:59 2621第一篇 解剖JavaScript中的null和undefine ... -
jQuery:基本教程
2009-09-30 15:24 1281jQuery:基本教程 这个教程是帮助初始学习jQuer ... -
javascript中获取浏览器的url
2009-09-03 18:47 1708document.location location.hre ... -
java中final与static关键字
2009-08-08 11:21 1464一.final总结 1.final修饰 ... -
linux下ssh安全配置
2009-07-09 13:25 3155linux下ssh安全配置 ssh配置文件目录: /etc ... -
python 学习笔记(一)
2009-05-17 10:40 925(一)软件的安装与配置 1.Python安装(Windows ... -
Mysql数据库导入导出
2009-05-15 16:25 15961. 概述MySQL数据库的导入,有两种方法:1) 先导出数据 ... -
Apache Commons Digester 的使用
2009-05-06 20:41 1255Learning and Using Jakarta Dige ... -
rpm软件管理
2009-04-30 20:26 1366RPM套件安裝 一、基本安裝 rpm -ivh 軟體套件 ... -
linux系统启动详解
2009-04-28 19:28 1265本文以RedHat9.0和i386平台 ... -
解读<c:out>源码
2009-04-23 17:43 3424<c:out>标签是用来在页面中输出属性值,在使用 ... -
使用 MERGE 语句更新表和视图内容
2009-04-20 12:37 1932DB2® 数据库管理器能够使用来自另一个源的数据(通常是表引用 ... -
高质量JAVA:错误模式
2009-04-08 11:43 796错误模式:介绍 诊断和纠正 Java 程序中反复出现 ... -
电器销售需求分析
2009-04-05 15:52 1032电器销售需求分析 doc 基本完成 基本 ... -
汇编编程推荐书目
2009-04-05 15:01 1400书名:《Windows环境 ... -
w3school帮助文档
2009-04-05 14:35 1283w3school帮助文档 中文版 chm
相关推荐
ANSI C标准库函数源代码 如strcat,strcpy,memmvoe库函数
ACM,函数,c语言 函数名: atof 功 能: 把字符串转换成浮点数 用 法: double atof(const char *nptr); 程序例: #include #include int main(void) { float f; char *str = "12345.67"; f = atof(str); printf...
C语言函数及相关知识 函数名: abort 功 能: 异常终止一个进程 用 法: void abort(void); 程序例: #include #include <stdlib.h> int main(void) { printf("Calling abort()\n"); abort(); return 0; /* This ...
atof函数 内置2个实现函数,可以从一个字符串中提取出数字信息并转换成浮点型数据
atoi和atof函数的区别及两个函数的功能分别是什么!
c语言函数集合,isalpha、atol、atof、calloc、malloc等,包括所有C语言的库函数,即查即用
里面包含了C语言函数库里面字符串的函数 例如atof等
本组建主要用于在程序中解析预先编写的类C脚本,并依据脚本执行,可通过调用外部指针函数读入输入变量执行计算,最终得出计算结果写入输出变量中;用户可通过读取输出变量获取最终的结果。 脚本中可调用函数,函数...
Linux相关函数说明. 字符测试函数(isblank..),数据转换函数(atoi,atof...)
atoi和atof函数的讲解,内涵讲解,库函数说明原理!
移植功能,如计算器,C语言某些平台中没有C库中函数atof,ftoa,需要自己实现。
包括的函数: atof 将字符串转换成浮点型数 atoi 将字符串转换成整型数 atol 将字符串转换成长整型数 gcvt 将浮点型数转换为字符串,取四舍五入 strtod 将字符串转换成长整型数 strtol 将字符串转换成长整型数 ...
C语言常用数字和字符串转换函数,toi 字符串转换成整型数 atol 字符串转换成长整型数 atof 字符串转换成浮点型数 strtol 字符串转换成长整型数 strtoul 字符串转换成无符号长整型数 strtod 字符串转换成浮点数
atoi函数、atol函数、atof函数:转换字符串 333 总结 336 第12章 结构体 339 12-1 结构体 340 数据关联性 340 结构体 342 结构体成员和运算符 344 成员的初始化 345 结构体成员和->运算符 346 结构体和...
atof(将字符串转换成浮点型数) atoi(将字符串转换成整型数) atol(将字符串转换成长整型数) strtod(将字符串转换成浮点数) strtol(将字符串转换成长整型数) strtoul(将字符串转换成无符号长整型数) toascii(将整型数...
字符串是Auto Lisp的基本数据之一,它常用于磁盘文件名,标识符的打印名等。Auto Lisp语言和其它高级语言一样,提供了一些字符串进行处理的系统... ·ATOF ·RTOS ·ANGTOS ·STRCAT ·SUBSTR ·STRCASE ·READ
Python的控制台功能简编(类似于BC conio.h)实际上:atof(s):btoi(ch):btos(ch):charfilter(ch):clrscr(n = 150):cmp(a,b): finput(b =“”):getarrow():getch():gotoxy(x = 0,y = 0...
atof();将字符转化为浮点型 例:char ch3;float f=atof(ch3); strtod(); 将字符串转化为双精度类型 例:string str1;double d=strtod(str1); strtol(); 将字符串转化为长整型 例:string str2; long int li=...
30.5 atof函数 30.6 atoi函数 30.7 atol函数 30.8 bsearch函数 30.9 div函数 30.10 exit函数 30.11 getenv函数 30.12 labs函数 30.13 ldiv函数 30.14 longjmp函数 30.15 mblen函数 30.16 mbstowes函数 30.17 mbtowc...
1.10.4 -c编译 16 1.10.5 链接 16 1.11 操作系统结构 17 1.11.1 用户模式 17 1.11.2 内核模式 17 1.12 64位,32位系统区别 18 1.12.1 CPU内部结构与寄存器 18 1.12.2 RISC与CISC CPU构架 18 1.12.3 SPARC,x86与ARM ...