Skip to content

Latest commit

 

History

History
97 lines (78 loc) · 1.78 KB

File metadata and controls

97 lines (78 loc) · 1.78 KB
title language
PMOD
zh-CN

描述

返回模运算 x mod y 在模系中的最小正数解,即通过计算 (x % y + y) % y 得出结果。

语法

PMOD(<x> , <y>)

参数

参数 说明
<x> 被除数
<y> 除数 不能为0

返回值

返回一个整型或浮点数。特殊情况:

  • 当 x=0 时,返回0。
  • 当 x is NULL 或 y is NULL时,返回NULL。

举例

SELECT PMOD(13,5);
+-------------+
| pmod(13, 5) |
+-------------+
|           3 |
+-------------+
SELECT PMOD(-13,5);
+--------------+
| pmod(-13, 5) |
+--------------+
|            2 |
+--------------+
SELECT PMOD(0,-12);
+--------------+
| pmod(0, -12) |
+--------------+
|            0 |
+--------------+
SELECT PMOD(0,null);
+-------------------------------+
| pmod(cast(0 as DOUBLE), NULL) |
+-------------------------------+
|                          NULL |
+-------------------------------+