本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
算術
下表顯示了可與 JSON 表達式語言搭配使用的算術表達式。
| 作業 | 表達式 | 輸入 | Output |
|---|---|---|---|
| 加法 | ["+", operand1, operand2] |
{ sum: ["+", 2, 4] } |
{ sum: 6 } |
| 減法 | ["-", operand1, operand2] |
{ difference: ["-", 10, 3] } |
{ difference: 7 } |
| 乘法 | ["*", operand1, operand2] |
{ product: ["*", 5, 6] } |
{ product: 30 } |
| 除法 | ["/", operand1, operand2] |
{ quotient: ["/", 20, 4] } |
{ quotient: 5 } |
| 模數 | ["%", operand1, operand2] |
{ remainder: ["%", 15, 4] } |
{ remainder: 3 } |
| 指數 | ["**", base, exponent] |
{ power: ["**", 2, 3] } |
{ power: 8 } |
| 絕對值 | ["abs", operand] |
{ absolute: ["abs", -5] } |
{ absolute: 5 } |
| Square Root (平方根) | ["sqrt", operand] |
{ sqroot: ["sqrt", 16] } |
{ sqroot: 4 } |
| 對數 (以 10 為底) | ["log10", operand] |
{ log: ["log10", 100] } |
{ log: 2 } |
| 自然對數 | ["ln", operand] |
{ ln: ["ln", Math.E] } |
{ ln: 1 } |
| 四捨五入 | ["round", operand] |
{ rounded: ["round", 3.7] } |
{ rounded: 4 } |
| 向下取整 | ["floor", operand] |
{ floor: ["floor", 3.7] } |
{ floor: 3 } |
| 向上取整 | ["ceil", operand] |
{ ceiling: ["ceil", 3.2] } |
{ ceiling: 4 } |
| 正弦波 | ["sin", operand] |
{ sine: ["sin", 0] } |
{ sine: 0 } |
| 餘弦 | ["cos", operand] |
{ cosine: ["cos", 0] } |
{ cosine: 1 } |
| 切線 | ["tan", operand] |
{ tangent: ["tan", Math.PI] } |
{ tangent: 0 } |