ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
# TypeScript 算术运算符 > 原文: [https://howtodoinjava.com/typescript/arithmetic-operators/](https://howtodoinjava.com/typescript/arithmetic-operators/) 运算符是代表特定动作的符号。 算术运算符可以与一个或多个值一起使用以产生单个值。 在 TypeScript 中,我们可以使用下面给出的 10 个运算符执行算术运算。 ## 算术运算符 `x + y`,加法,相加两个操作数。 ```java let x = 10; let y = 20; let z = x + y; console.log( z ); //Output 30 ``` `x - y`,减法,相减两个操作数。 ```java let x = 10; let y = 20; let z = x - y; console.log( z ); //Output -10 ``` `-x`,取反,翻转标志,求相反数。 ```java let x = 10; let z = -x; console.log( z ); //Output -10 ``` `x * y`,乘法,相乘两个运算符。 ```java let x = 10; let y = 20; let z = x * y; console.log( z ); //Output 200 ``` `x ** y`,求幂,将第一个操作数乘以自己,重复第二个操作数指示的次数。 ```java let x = 10; let y = 20; let z = x ** y; console.log( z ); //Output 100000000000000000000 or 1e+20 ``` `x / y`,除法,分子除以分母。 ```java let x = 10; let y = 20; let z = x / y; console.log( z ); //Output 2 ``` `x % y`,模量,返回整数除法后的余数。 ```java let x = 10; let y = 20; let z = x % y; console.log( z ); //Output 10 ``` `x++`,递增,将整数值增加一。 ```java let x = 10; x++; console.log( x ); //Output 11 ``` `x--`,递减,将整数值减一。 ```java let x = 10; x--; console.log( x ); //Output 9 ``` 以上是 TypeScript 中使用的**算术运算符**。 将我的问题放在评论部分。 学习愉快!