Cadence_Skill_语法详解(中文)概要1.docVIP

  • 9
  • 0
  • 约2.27万字
  • 约 40页
  • 2017-07-03 发布于湖北
  • 举报
Cadence_Skill_语法详解(中文)概要1

常量、变量 常量是它的值等于自身的表达式,如123,”abc”… 变量是保存了其它值的表达式,如x=3, x即变量。 算术与逻辑操作符 函数名 语法 对应操作符 Data Access arrayref a[index] [ ] setarray a[index] = expr bitfield1 xbit setqbitfield1 xbit=expr setqbitfield xmsb:lsb=expr quote expr getqq g.s . getq g-s - putpropqq g.s=expr, g-s=expr putpropq d~s, d~s =expr ~ Unary preincrement ++s ++ postincrement s++ ++ predecrement --s -- postdecrement s-- -- minus -n - not !expr ! bnot ~x ~ Binary expt n1 ** n2 ** times n1 * n2 * quotient n1 / n2 / plus n1 + n2 + difference n1 - n2 - leftshift x1 x2 rightshift x1 x2 lessp n1n2 greaterp n1n2 leqp n1=n2 = geqp n1=n2 = equal g1 == g2 == nequal g1 != g2 != band x1 x2 bnand x1 ~ x2 ~ bxor x1 ^ x2 ^ bxnor x1 ~^ x2 ~^ bor x1 | x2 | bnor x1 ~| x2 ~| and x1 x2 or x1 || x2 || range g1 : g2 : setq s = expr = 对于既有函数名又有操作符函数,采用函数名调用和采用操作符调用的效果是一样的。 示例 lessp(3 1)=nil 等同于 31=nil 预定义算术函数 语法 结果 通用函数 add1(n) n + 1 sub1(n) n – 1 abs(n) 绝对值 exp(n) 自然对数的n次方 log(n) max(n1 n2 ...) min(n1 n2 ...) mod(x1 x2) 取模运算 round(n) sqrt(n) sxtd(x w) 将x右扩展W个符号位 zxtd(x w) 和上面的功能相同,速度更快 三角函数 sin(n),cos(n),tan(n) asin(n),acos(n),atan(n) 随机数生成函数 random(x) 产生0~x-1的随机数 srandom(x)

文档评论(0)

1亿VIP精品文档

相关文档