IDL出现% Program caused arithmetic error: Floating illegal operand 错误!!
来源:互联网 发布:sql2000备份数据库 编辑:程序博客网 时间:2024/05/17 09:20
用IDL处理NaN数据时,用到where函数时,经常会出现Program caused arithmetic error: Floating illegal operand 错误,查了下发现官网有说明,记录下防下次出错!!
Special Floating-Point Values
Machines which implement the IEEE standard for binary floating-point arithmetic have two special values for undefined results: NaN (Not A Number) and Infinity. Infinity results when a result is larger than the largest representation. NaN is the result of an undefined computation such as zero divided by zero, taking the square-root of a negative number, or the logarithm of a non-positive number. In many cases, when IDL encounters the value NaN in a data set, it treats it as “missing data.” The special values NaN and Infinity are also accessible in the read-only system variable !VALUES. These special operands propagate throughout the evaluation process—the result of any term involving these operands is one of these two special values.
Note: For the minimum (<) and maximum (>) operators with NaN operands, the result is undefined and may not necessarily be the special value NaN.
For example:
; Multiply NaN by 3
PRINT, 3 * !VALUES.F_NAN
IDL prints:
NaN
It is important to remember that the value NaN is literally not a number, and as such cannot be compared with a number. For example, suppose you have an array that contains the value NaN:
A = [1.0, 2.0, !VALUES.F_NAN, 3.0]
PRINT, A
IDL prints:
1.00000 2.00000 NaN 3.0000
If you try to select elements of this array by comparing them with a number (using the WHERE function, for example), IDL might generate an error (depending on the hardware and operating system):
; Print the indices of A that are not equal to 1
PRINT, WHERE( A NE 1.0 )
IDL prints:
1 2 3
% Program caused arithmetic error: Floating illegal operand
(Depending on your hardware and operating system, you may not see the floating-point error.)
To avoid this problem, use the FINITE function to make sure arguments to be compared are in fact valid floating-point numbers:
PRINT, WHERE( FINITE(A) )
IDL prints the indices of the finite elements of A:
0 1 3
To then print the indices of the elements of A that are both finite and not equal to 1.0, you could use the command:
good = WHERE( FINITE(A) )
PRINT, good[WHERE(A[good] NE 1.0)]
IDL prints:
1 3
Similarly, if you wanted to find out which elements of an array were not valid floating-point numbers, you could use a command like:
; Print the indices of the elements of A that are not valid
; floating-point numbers.
PRINT, WHERE( ~FINITE(A) )
IDL prints:
2
Note that the special value Infinity can be compared to a floating point number. Thus, if:
B = [1.0, 2.0, !VALUES.F_INFINITY]
PRINT, B
IDL prints:
1.00000 2.00000 Inf
and
PRINT, WHERE(B GT 1.0)
IDL prints:
1 2
You can also compare numbers directly with the special value Infinity:
PRINT, WHERE(B EQ !VALUES.F_INFINITY)
IDL prints:
2
Note: On Windows, using relational operators such as EQ and NE with the values infinity or NaN (Not a Number) causes an “illegal operand” error. The FINITE function’s INFINITY and NAN keywords can be used to perform comparisons involving infinity and NaN values. For more information, see FINITE.
- IDL出现% Program caused arithmetic error: Floating illegal operand 错误!!
- IDL出现% Program caused arithmetic error: Floating illegal operand 错误!!
- BC31 , floating point error:domain 错误解决方法
- suggest parentheses around arithmetic in operand of '|'
- The IEEE standard for floating point arithmetic
- 浮点数计算(Floating-point arithmetic)
- error: stray '\32' in program 错误
- 【编译错误】error:stray'\243'in program
- linux c之gcc编译出现error:lvalue required as unary '&' operand解决办法
- JNI错误之:error: base operand of '->' has non-pointer type '_JNIEnv'
- Fatal error: Unsupported operand types108
- error C2443: operand size conflict
- vs 提示错误error C2017: illegal escape sequence
- Flex错误1053:verifyerror error #1053 illegal over.
- js中出现TypeError: invalid 'in' operand a的错误解决
- android cmake编译faad库,出现 invalid operand for inline asm constraint 'M'错误
- WINCE 编译的时候出现错误 illegal indirection
- JSON.parse在手机浏览器上出现illegal access错误
- 提高工作效率的三个方法
- 多线程死锁例子
- for语句
- OkHttp源码解析(四)——失败重连
- 关于java线程池和相关
- IDL出现% Program caused arithmetic error: Floating illegal operand 错误!!
- 多线程编程 RW_LOCK 读写锁
- Thinking in Java——第二章-一切都是对象
- 使用 IOS7 原生API进行二维码条形码的扫描
- eclipse最常用快捷键整理
- 双缓冲绘图
- yum源配置EPEL
- POJ:3620 Avoid The Lakes(深搜DFS)
- Closure表 冗余 小结