expression.
■ Boolean - true and false
■ Integer - As defined by the IntegerLiteral construct in Section 1.19
■ Floating point - As defined by the FloatingPointLiteral construct in
Section 1.19
■ String - With single and double quotes - " is escaped as \", ' is escaped as \',
and \ is escaped as \\. Quotes only need to be escaped in a string value enclosed
in the same type of quote
■ Null - null
也规定了操作符的运算规则,如+ - *:
Java代码 1.3 Literals
There are literals for boolean, integer, floating point, string, and null in an eval-expression.
■ Boolean - true and false
■ Integer - As defined by the IntegerLiteral construct in Section 1.19
■ Floating point - As defined by the FloatingPointLiteral construct in
Section 1.19
■ String - With single and double quotes - " is escaped as \", ' is escaped as \',and \ is escaped as \\. Quotes only need to be escaped in a string value enclosed in the same type of quote
■ Null - null
■ If operator is -, return A.subtract(B)
■ If operator is *, return A.multiply(B)
■ If A or B is a Float, Double,or String containing ., e,or E:
■ If A or B is BigInteger, coerce both A and B to BigDecimal and apply operator.
■ Otherwise, coerce both A and B to Double and apply operator
■ If A or B is BigInteger, coerce both to BigInteger and then:
■ If operator is +, return A.add(B)
■ If operator is -, return A.subtract(B)
■ If operator is *, return A.multiply(B)
■ Otherwise coerce both A and B to Long and apply operator
■ If operator results in exception, error
如Integer型,直接交给前边介绍的IntegerLiteral。ognl表达式和el表达式
即规范中其实已经规范了这些,但是就像java里的一些东西,虽然规范规定了(如排序时 很有时候使用 return a-b; 如果a是负数则可能溢出),但是还是很容易出错。
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-31947-4.html
就是阻滞中国的发展
逼它开跑