将字符串转为数字
来源:互联网 发布:南京国土局网络问政 编辑:程序博客网 时间:2024/04/30 02:00
要求:将字符串转化为对应的数值,如‘123’转为 1.2300000000000000E+02, ‘123a’会转化为0.0000000000000000E+00。
当字符串为空,先赋给它为‘0’.
data: ZUEGNRT_STR type c LENGTH 5 , res type c LENGTH 1.
DATA: ZUEGNRT_F TYPE F,ZUEKFRT_F TYPE F.
ZUEGNRT_STR = '123'.
CONDENSE ZUEGNRT_STR NO-GAPS.
if ZUEGNRT_STR = ''.
ZUEGNRT_STR = '0'.
ENDIF.
CALL FUNCTION 'CHAR_FLTP_CONVERSION' "Format conversion: Character --> Floating point
EXPORTING
* dyfld = SPACE " Screen Field name for cursor positioning
* maskn = SPACE " Masking character if input screen
* maxdec = '16' " t006-decan Maximum number of input decimal places
* maxexp = '59+' " t006-expon Maximum gross power of 10
* minexp = '60-' " t006-expon Minimum gross power of 10
string = ZUEGNRT_STR " CHAR input field for conversion to FLTP
* msgtyp_decim = 'W' " sref-msgtyp Message type for 'TOO_MANY_DECIM' (see domains)
IMPORTING
" decim = 2 " Number of decimal places determined
" expon = 3 " Gross power of 10 determined
flstr = ZUEGNRT_F " FLTP output field, from CHAR conversion
" ivalu = 'X' " Value in STR;ING flag
EXCEPTIONS
EXPONENT_TOO_BIG = 1 " Gross power of 10 is too big
EXPONENT_TOO_SMALL = 2 " Gross power of 10 is too small
STRING_NOT_FLTP = 3 " STRING cannot be interpreted as floating point
TOO_MANY_DECIM = 4 " Too many decimal places
OTHERS = 5.
if ZUEGNRT_F > 0 .
res = 'Y'.
else.
res = 'N'.
ENDIF.
write: / ZUEGNRT_F.
- 将字符串转为数字
- 将字符串转为数字
- Oracle将字符串转为数字
- awk将字符串转为数字的方法
- C++将数字转为字符串,并拼接
- C++将数字转为字符串,并拼接
- 将数字转为二、十、十六进制字符串
- sprintf将数字转为字符串,或格式化字符串
- C语言将一个字符串的字符转为一个数字
- mysql将字符串字段转为数字排序或比大小
- 数字转为定长字符串
- oracle数字转为字符串
- 字符串转为数字
- 字符串转为数字
- 字符串数字转为double
- 字符串转为数字。字符串转为数组。
- 将整型转为字符串
- 将文本文件转为字符串
- List of HTTP headers
- 基于信号量的线程同步
- gdb之调试多进程程序
- [Go Raspberry] I 启动树莓派
- c++类库
- 将字符串转为数字
- SQL行列转换-合并列值(示例)
- expect的基本用法
- SQL 中字符串连接
- 用二级指针删除单链表的一个节点
- Java与Delphi交叉DES加解密的问题
- 在 Ubuntu 12.04 Server 中修改用户名和主机名
- 读取中英文混搭的文件
- Windows界面编程第六篇 动画启动效果(动画效果显示及隐藏窗口)