binary_float_nan和binary_double_nan

304的的哥 2010-12-28 11:38:49

--这里有个测试表
SQL> create table binary_test
2 (bin_float binary_float,
3 bin_double binary_double)

--向表中添加数据并查看

SQL> insert into binary_test(
2 bin_float,bin_double)
3 values(39.5f,15.7d)
4 /

1 row inserted

SQL> insert into binary_test(bin_float,bin_double)
2 values(binary_float_infinity,binary_double_infinity);

1 row inserted

SQL> select * from binary_test;

BIN_FLOAT BIN_DOUBLE
---------- ----------
39.5 15.7
1E126 1E126

--但是当我执行下面的操作后,问题就来了

SQL> insert into binary_test(bin_float,bin_double)
2 values(binary_float_nan,binary_double_nan);
1 row inserted

SQL> select * from binary_test;
select * from binary_test
ORA-01722: 无效数字

--我明明向表中添加了3条数据,为啥查不出来呢?还显示为无效数子
--是不是我插入的binary_float_nan,binary_double_nan将前面的数字覆盖了,也认为那些数据为无效的数字呢?
--或者是数据的插入顺序其的作用?

SQL> rollback;
Rollback complete

SQL> select count(*) from binary_test;
COUNT(*)
----------
0

SQL> insert into binary_test(bin_float,bin_double)
2 values(binary_float_nan,binary_double_nan);
1 row inserted

SQL> select * from binary_test;
select * from binary_test

ORA-01722: 无效数字

SQL> insert into binary_test(bin_float,bin_double)
2 values(36.12f,564.1545d);
1 row inserted

--当我查看表中的数据时,有两条数据
SQL> select count(*) from binary_test;
COUNT(*)
----------
2

--但是我查看时,还是显示为无效数字

SQL> select * from binary_test;
select * from binary_test

ORA-01722: 无效数字

这是什么问题呢?
...全文
526 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
304的的哥 2010-12-29
  • 打赏
  • 举报
回复

--原来是pl/sql developer的问题!
  • 打赏
  • 举报
回复

scott@YPCOST> insert into binary_test(
2 bin_float,bin_double)
3 values(39.5f,15.7d)
4 /

已创建 1 行。

scott@YPCOST> ed
已写入 file afiedt.buf

1 insert into binary_test(bin_float,bin_double)
2* values (binary_float_infinity,binary_double_infinity);
scott@YPCOST> /
values (binary_float_infinity,binary_double_infinity);
*
第 2 行出现错误:
ORA-00911: 无效字符

--解释下为什么上面的语句会报错 因为是通过ed进行编辑的 然后通过回车符进行执行
--最后一个;就是多余的了
scott@YPCOST> ed
已写入 file afiedt.buf

1 insert into binary_test(bin_float,bin_double)
2* values (binary_float_infinity,binary_double_infinity)
scott@YPCOST> /

已创建 1 行。

--例如上面把;去掉就正常了
scott@YPCOST> ed\

scott@YPCOST> ed
已写入 file afiedt.buf

1* select * from binary_test;
scott@YPCOST> /
select * from binary_test;
*
第 1 行出现错误:
ORA-00911: 无效字符

--这个也是同样的道理
--而下面的语句是直接写的语句(没有通过ed进行编辑) 用;结束 然后执行
scott@YPCOST> select * from binary_test;

BIN_FLOAT BIN_DOUBLE
---------- ----------
3.95E+001 1.57E+001
Inf Inf
心中的彩虹 2010-12-28
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 oraclefans_ 的回复:]
引用 14 楼 wkc168 的回复:

引用 13 楼 wkc168 的回复:
引用 12 楼 oraclefans_ 的回复:
binary_float_nan,binary_double_nan 在数据里存储的是IS NaN ,IS INF
不要用 PL/SQL Developer 作此实验,在plsql下不支持数据和nan同时显示,
可以用 SQL*Plus,其实就和 IS N……
[/Quote]
应该开发的人晓得会改进
Oraclefans_ 2010-12-28
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 wkc168 的回复:]

引用 13 楼 wkc168 的回复:
引用 12 楼 oraclefans_ 的回复:
binary_float_nan,binary_double_nan 在数据里存储的是IS NaN ,IS INF
不要用 PL/SQL Developer 作此实验,在plsql下不支持数据和nan同时显示,
可以用 SQL*Plus,其实就和 IS NULL 一样。 NULL 用于在数据库
的……
[/Quote]
哎。。。。。。
心中的彩虹 2010-12-28
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 wkc168 的回复:]
引用 12 楼 oraclefans_ 的回复:
binary_float_nan,binary_double_nan 在数据里存储的是IS NaN ,IS INF
不要用 PL/SQL Developer 作此实验,在plsql下不支持数据和nan同时显示,
可以用 SQL*Plus,其实就和 IS NULL 一样。 NULL 用于在数据库
的所有数据类型的列中存储“不知道”,然后用 I……
[/Quote]
还是PL/SQL Developer 不支持
心中的彩虹 2010-12-28
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 oraclefans_ 的回复:]
binary_float_nan,binary_double_nan 在数据里存储的是IS NaN ,IS INF
不要用 PL/SQL Developer 作此实验,在plsql下不支持数据和nan同时显示,
可以用 SQL*Plus,其实就和 IS NULL 一样。 NULL 用于在数据库
的所有数据类型的列中存储“不知道”,然后用 IS NULL 来判断。
现在 NaN用于在 BIN……
[/Quote]




SQL> create table binary_test
2 (bin_float binary_float,
3 bin_double binary_double)
4 /

Table created

SQL>
SQL> insert into binary_test(
2 bin_float,bin_double)
3 values(39.5f,15.7d)
4 /

1 row inserted

SQL>
SQL> insert into binary_test(bin_float,bin_double)
2 values(binary_float_infinity,binary_double_infinity);

1 row inserted

SQL> commit
2 /

Commit complete

SQL> select * from binary_test
2 /

BIN_FLOAT BIN_DOUBLE
---------- ----------
39.5 15.7
1E126 1E126

SQL>
SQL> insert into binary_test(bin_float,bin_double)
2 values(binary_float_nan,binary_double_nan)
3 /

1 row inserted

SQL> commit
2 /

Commit complete

SQL> select * from binary_test
2 /

select * from binary_test

ORA-01722: 无效数字


SQL> select count(*) from binary_test
2 /

COUNT(*)
----------
3

SQL>



--sqlplus 下则可以 是的如楼上说 的
scott@ORCL> select * from binary_test
2 /

BIN_FLOAT BIN_DOUBLE
---------- ----------
3.95E+001 1.57E+001
Inf Inf
Nan Nan
Oraclefans_ 2010-12-28
  • 打赏
  • 举报
回复
binary_float_nan,binary_double_nan 在数据里存储的是IS NaN ,IS INF
不要用 PL/SQL Developer 作此实验,在plsql下不支持数据和nan同时显示,
可以用 SQL*Plus,其实就和 IS NULL 一样。 NULL 用于在数据库
的所有数据类型的列中存储“不知道”,然后用 IS NULL 来判断。
现在 NaN用于在 BINARY_DOUBL/BINARY_FLOAT 浮点类型
的列中存储“不是数字”和“无限数字”,然后用 IS NaN或者是is inf
具体测试如下

SQL> create table binary_test
2 (bin_float binary_float,
3 bin_double binary_double);

表已创建。

SQL> insert into binary_test (bin_float, bin_double) values (39.5f, 15.7d);

已创建 1 行。

SQL> commit;

提交完成。

SQL> insert into binary_test(bin_float,bin_double)
2 values(binary_float_infinity,binary_double_infinity);

已创建 1 行。

SQL> commit;

提交完成。

SQL> insert into binary_test(bin_float,bin_double)
2 values(binary_float_nan,binary_double_nan);

已创建 1 行。

SQL> commit;

提交完成。

SQL> select * from binary_test;

BIN_FLOAT BIN_DOUBLE
---------- ----------
3.95E+001 1.57E+001
Inf Inf
Nan Nan

SQL> select * from binary_test where bin_float is NAN;

BIN_FLOAT BIN_DOUBLE
---------- ----------
Nan Nan

SQL>



304的的哥 2010-12-28
  • 打赏
  • 举报
回复

--也就是说nan影响到了整个查询了!
--那可不可一得出这样的结论呢?
--当表里面有一个binary_float或binary_double类型列时,给其赋值nan
--将会影响到所有关于此列的select * 或者select a.*的查询操作?
304的的哥 2010-12-28
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 minitoy 的回复:]

没用过这类型.貌似nan的数据没法正常读取.所以你取3条的时候就不成.
[/Quote]

--也就是说nan影响到了整个查询了!
--那可不可一得出这样的结论呢?
--当表里面有一个binary_float或binary_double类型列时,给其赋值nan,将会影响到所有的查询操作?
minitoy 2010-12-28
  • 打赏
  • 举报
回复
没用过这类型.貌似nan的数据没法正常读取.所以你取3条的时候就不成.
304的的哥 2010-12-28
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 minitoy 的回复:]

SQL code
SQL> select count(*) from test_binary;

select count(*) from test_binary

ORA-00942: 表或视图不存在

SQL> select count(*) from binary_test;

COUNT(*)
----------
3

SQL> select * fr……
[/Quote]

--为何执行这句话的时候,什么也查不出来呢?是第三条数据(非数)影响到了整个查询吗?
SQL> select * from binary_test where rownum<=3;

select * from binary_test where rownum<=3

ORA-01722: invalid number
304的的哥 2010-12-28
  • 打赏
  • 举报
回复

--谢谢各位的积极参与
SQL> select to_char(bin_float) cl,to_char(bin_double) c2 from binary_test where rownum<=3;

CL C2
---------------------------------------- ----------------------------------------
Nan Nan
3.61199989E+001 5.6415449999999998E+002

minitoy 2010-12-28
  • 打赏
  • 举报
回复
SQL> select * from binary_test t where t.bin_float !=binary_float_nan;

BIN_FLOAT BIN_DOUBLE
---------- ----------
39.5 15.7
1E126 1E126

SQL>
minitoy 2010-12-28
  • 打赏
  • 举报
回复
SQL> select count(*) from test_binary;

select count(*) from test_binary

ORA-00942: 表或视图不存在

SQL> select count(*) from binary_test;

COUNT(*)
----------
3

SQL> select * from binary_test where rownum<=1;

BIN_FLOAT BIN_DOUBLE
---------- ----------
39.5 15.7

SQL> select * from binary_test where rownum<=2;

BIN_FLOAT BIN_DOUBLE
---------- ----------
39.5 15.7
1E126 1E126

SQL> select * from binary_test where rownum<=3;

select * from binary_test where rownum<=3

ORA-01722: invalid number

SQL>
304的的哥 2010-12-28
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zhuomingwang 的回复:]

SQL code

scott@YPCOST> insert into binary_test(
2 bin_float,bin_double)
3 values(39.5f,15.7d)
4 /

已创建 1 行。

scott@YPCOST> ed
已写入 file afiedt.buf

1 insert into binary_test(bin_float,bi……
[/Quote]

--你没理解我的意思,首先我的操作没有错误!嘿嘿
--我是想知道,为什么我添加到表中的两条数据怎么查不出来?
--我知道他两binary_float_nan,binary_double_nan是非binary_float和binary_double的数字,但是明明另外--还有一条数据的,怎么那条数据也不会显示出来呢?
--而我是通过PL/SQL Developer编辑的,没用到ed命令在notepad里面编辑。
心中的彩虹 2010-12-28
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zhuomingwang 的回复:]
SQL code

scott@YPCOST> insert into binary_test(
2 bin_float,bin_double)
3 values(39.5f,15.7d)
4 /

已创建 1 行。

scott@YPCOST> ed
已写入 file afiedt.buf

1 insert into binary_test(bi……
[/Quote]

对的 多了 分号
tangren 2010-12-28
  • 打赏
  • 举报
回复
binary_float_nan 表示不是一个二进制浮点数,当然就不是一个binary_float类型
binary_double_nan 表示不是一个二进制双精度浮点数,当然就不是一个binary_double类型
既然不是binary_float和binary_double类型,就不要向此类型的列中插入,
报not a number是自然的。
binary_float_infinity,binary_double_infinity,它是这个类型自然是没有问题的。
FASMARM v1.42 This package is an ARM assembler add-on for FASM. FASMARM currently supports the full range of instructions for 32-bit and 64-bit ARM processors and coprocessors up to and including v8. Contents: 1. ARM assembly compatibility 2. UAL and pre-UAL syntaxes 3. IT block handling 4. Alternate encodings 5. Output formats 6. Control directives 7. Data definitions 8. Defining registers lists inside macros 9. Half-precision number formatting 10. Variants supported 11. Further information 12. Version history _______________________________________________________________________________ 1. ARM assembly compatibility There are a few restrictions how the ARM instruction set is implemented. The changes are minor and mostly have a minor impact. For the most part the basic instruction outline is the same. Where possible the original style is used but there are some differences: Not everything matches the ARM ADS assembly style, where possible the original style is used but there are some differences 1) label names cannot begin with a digit 2) CPSIE and CPSID formats are changed, use "iflags_aif" form instead of "aif" (eg. "CPSIE iflags_i" instead of "CPSID i") 3) SRS with writeback must have a separating space after the mode number and before "!" (eg. "SRSDB 16 !" instead of "SRSDB 16!") 4) macro, rept, irp, format, if, virtual etc. are all significant changes from the ARM ADS, so you will need to re-write those sections of existing code Original ARM Syntax | fasmarm Syntax ----------------------+---------------------- cpsie a | cpsie iflags_a | srsdb #29! | srsdb #29 ! ;or, | srsdb 29 ! _______________________________________________________________________________ 2. UAL and pre-UAL syntaxes fasmarm supports the original pre-UAL syntax and the newer UAL syntax. These two syntaxes only affect THUMB encodings. UAL stands for: Universal Assembly Language. pre-UAL syntax is selected wi

3,491

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧