一、算术运算符
Expression | Name | Description |
---|---|---|
+x | unary plus | the identity operation |
-x | unary minus | maps values to their additive inverses |
x + y | binary plus | performs addition |
x - y | binary minus | performs subtraction |
x * y | times | performs multiplication |
x / y | divide | performs division |
x ÷ y | integer divide | x / y, truncated to an integer |
x \ y | inverse divide | equivalent to y / x |
x ^ y | power | raises x to the y th power |
x % y | remainder | equivalent to rem(x,y) |
!x | negation | changes true to false and vice versa |
二、位运算符
Expression | Name |
---|---|
~x | bitwise not |
x & y | bitwise and |
x | y | bitwise or |
x ⊻ y | bitwise xor (exclusive or) 这个东西特别!!输入\xor -tab |
x >>> y | logical shift right |
x >> y | arithmetic shift right |
x << y | logical/arithmetic shift left |
三、数值比较运算
Operator | Name |
---|---|
== | equality |
!= , ≠ | inequality |
< | less than |
<= , ≤ | less than or equal to |
> | greater than |
>= , ≥ | greater than or equal to |
支持连续比较。
Function | Tests 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 |
四、运算符优先级和关联性
Category | Operators | Associativity |
---|---|---|
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 |
舍入功能
Function | Description | Return type |
---|---|---|
round(x) | round x to the nearest integer | typeof(x) |
round(T, x) | round x to the nearest integer | T |
floor(x) | round x towards -Inf | typeof(x) |
floor(T, x) | round x towards -Inf | T |
ceil(x) | round x towards +Inf | typeof(x) |
ceil(T, x) | round x towards +Inf | T |
trunc(x) | round x towards zero | typeof(x) |
trunc(T, x) | round x towards zero | T |
除法相关函数:
Function | Description |
---|---|
div(x,y) , x÷y | truncated 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