Julia之初体验(三)运算符

一、算术运算符

ExpressionNameDescription
+xunary plusthe identity operation
-xunary minusmaps values to their additive inverses
x + ybinary plusperforms addition
x - ybinary minusperforms subtraction
x * ytimesperforms multiplication
x / ydivideperforms division
x ÷ yinteger dividex / y, truncated to an integer
x \ yinverse divideequivalent to y / x
x ^ ypowerraises x to the yth power
x % yremainderequivalent to rem(x,y)
!xnegationchanges true to false and vice versa

二、位运算符

ExpressionName
~xbitwise not
x & ybitwise and
x | ybitwise or
x ⊻ ybitwise xor (exclusive or)  这个东西特别!!输入\xor  -tab 
x >>> ylogical shift right
x >> yarithmetic shift right
x << ylogical/arithmetic shift left

 

三、数值比较运算

OperatorName
==equality
!=, inequality
<less than
<=, less than or equal to
>greater than
>=, greater than or equal to

支持连续比较。

FunctionTests if
isequal(x, y)x and y are identical
isfinite(x)x is a finite number
isinf(x)x is infinite
isnan(x)x is not a number

四、运算符优先级和关联性

CategoryOperatorsAssociativity
Syntax. followed by ::Left
Exponentiation^Right
Unary+ - √Right[1]
Bitshifts<< >> >>>Left
Fractions//Left
Multiplication* / % & \ ÷Left[2]
Addition+ - | ⊻Left[2]
Syntax: ..Left
Syntax|>Left
Syntax<|Right
Comparisons> < >= <= == === != !== <:Non-associative
Control flow&& followed by || followed by ?Right
Pair=>Right
Assignments= += -= *= /= //= \= ^= ÷= %= |= &= ⊻= <<= >>= >>>=Right

 

舍入功能

FunctionDescriptionReturn type
round(x)round x to the nearest integertypeof(x)
round(T, x)round x to the nearest integerT
floor(x)round x towards -Inftypeof(x)
floor(T, x)round x towards -InfT
ceil(x)round x towards +Inftypeof(x)
ceil(T, x)round x towards +InfT
trunc(x)round x towards zerotypeof(x)
trunc(T, x)round x towards zeroT

除法相关函数:

FunctionDescription
div(x,y), x÷ytruncated division; quotient rounded towards zero
fld(x,y)floored division; quotient rounded towards -Inf
cld(x,y)ceiling division; quotient rounded towards +Inf
rem(x,y)remainder; satisfies x == div(x,y)*y + rem(x,y); sign matches x
mod(x,y)modulus; satisfies x == fld(x,y)*y + mod(x,y); sign matches y
mod1(x,y)mod with offset 1; returns r∈(0,y] for y>0 or r∈[y,0) for y<0, where mod(r, y) == mod(x, y)
mod2pi(x)modulus with respect to 2pi; 0 <= mod2pi(x)   < 2pi
divrem(x,y)returns (div(x,y),rem(x,y))
fldmod(x,y)returns (fld(x,y),mod(x,y))
gcd(x,y...)greatest positive common divisor of x, y,...
lcm(x,y...)least positive common multiple of x, y,...

 

今天学习到此,总体感觉Julia 整合了很多软件的功能。说得最多的是速度,但是由于运行第一次需要编译,速度较慢,第二次运行速度特别快。下次继续。

 

2020.5.21

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

bowen2006

你的鼓励是我的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值