Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc]modify pmod radians random #1940

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,76 @@ specific language governing permissions and limitations
under the License.
-->

## pmod
## Description

### description
#### Syntax
Returns the smallest positive solution of the modulo operation x mod y within the modular system, which is obtained by calculating (x % y + y) % y.

## Syntax

```sql
BIGINT PMOD(BIGINT x, BIGINT y)
DOUBLE PMOD(DOUBLE x, DOUBLE y)
PMOD(<x> , <y>)
```
Returns the positive result of x mod y in the residue systems.
Formally, return `(x%y+y)%y`.

### example
## Parameters

| Parameter | Description |
|-----------|------------|
| `<x>` | Dividend |
| `<y>` | Divisor should not be 0 |

## Return value

Returns an integer or a floating-point number. Special cases:

- If x = 0, returns 0.
- If x is NULL or y is NULL, returns NULL.

## Example

```sql
SELECT PMOD(13,5);
```
MySQL [test]> SELECT PMOD(13,5);

```text
+-------------+
| pmod(13, 5) |
+-------------+
| 3 |
+-------------+
```

MySQL [test]> SELECT PMOD(-13,5);
+-------------+
```sql
SELECT PMOD(-13,5);
```

```text
+--------------+
| pmod(-13, 5) |
+-------------+
| 2 |
+-------------+
+--------------+
| 2 |
+--------------+
```

```sql
SELECT PMOD(0,-12);
```

```text
+--------------+
| pmod(0, -12) |
+--------------+
| 0 |
+--------------+
```

```sql
SELECT PMOD(0,null);
```

### keywords
PMOD
```text
+-------------------------------+
| pmod(cast(0 as DOUBLE), NULL) |
+-------------------------------+
| NULL |
+-------------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,62 @@ specific language governing permissions and limitations
under the License.
-->

## radians
## Description

### description
#### Syntax

`DOUBLE radians(DOUBLE x)`
Returns the value of `x` in radians, converted from degrees to radians.

### example
## Syntax

```sql
RADIANS(<x>)
```
mysql> select radians(0);
+--------------+
| radians(0.0) |
+--------------+
| 0 |
+--------------+
mysql> select radians(30);
+---------------------+
| radians(30.0) |
+---------------------+
| 0.52359877559829882 |
+---------------------+
mysql> select radians(90);
+--------------------+
| radians(90.0) |
+--------------------+
| 1.5707963267948966 |
+--------------------+

## Parameters

| Parameter | Description |
|-----------|------------|
| `<x>` | The angle in degrees to be converted. |

## Return value

Returns an integer or a floating-point number. Special case:

- If the parameter x is NULL, it returns NULL.

## Example

```sql
select radians(0);
```

### keywords
RADIANS
```text
+----------------------------+
| radians(cast(0 as DOUBLE)) |
+----------------------------+
| 0.0 |
+----------------------------+
```

```sql
select radians(30);
```

```text
+-----------------------------+
| radians(cast(30 as DOUBLE)) |
+-----------------------------+
| 0.5235987755982988 |
+-----------------------------+
```

```sql
select radians(90);
```

```text
+-----------------------------+
| radians(cast(90 as DOUBLE)) |
+-----------------------------+
| 1.5707963267948966 |
+-----------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -22,58 +22,76 @@ specific language governing permissions and limitations
under the License.
-->

## random
## Description

### description
#### Syntax
Returns a random number between 0 and 1, or returns the required random number according to the parameters.

`DOUBLE random()`
Returns a random number between 0 and 1.
- Note: All parameters must be constants.

`DOUBLE random(DOUBLE seed)`
Returns a random number between 0 and 1, seeded with `seed`.
## Alias

`BIGINT random(BIGINT a, BIGINT b)`
Returns a random number between a and b. a must be less than b.
- RAND

Alias: `rand`.
## Syntax

Note: All parameters must be constants.
```sql
RANDOM() -- Generates a random number between 0 and 1

RANDOM(<seed>) -- Generates a fixed sequence of random numbers between 0 and 1 based on the seed value

RANDOM(<a> , <b>) -- Generates a random number between a and b
```

## Parameters

| Parameter | Description |
|-----------|------------|
| `<seed>` | random number generator seed. Returns a fixed sequence of random numbers between 0 and 1. |
| `<a>` | The lower bound of a random number. |
| `<b>` | The upper bound of a random number. It must be less than the lower bound. |

## Return value

### example
- If no parameters are passed: Returns a random number between 0 and 1.

- If a single parameter seed is passed: Returns a fixed sequence of random numbers between 0 and 1.

- If two parameters a and b are passed: Returns a random integer between a and b.

## Example

```sql
mysql> select random();
+---------------------+
| random() |
+---------------------+
| 0.35446706030596947 |
+---------------------+
select random();
```

mysql> select rand(1.2);
+---------------------+
| rand(1) |
+---------------------+
| 0.13387664401253274 |
+---------------------+
1 row in set (0.13 sec)
```text
+--------------------+
| random() |
+--------------------+
| 0.8047437125910604 |
+--------------------+
```

```sql
select rand(1.2);
```

mysql> select rand(1.2);
```text
+---------------------+
| rand(1) |
+---------------------+
| 0.13387664401253274 |
+---------------------+
1 row in set (0.11 sec)
```

mysql> select rand(-20, -10);
```sql
select rand(-20, -10);
```

```text
+------------------+
| random(-20, -10) |
+------------------+
| -13 |
| -10 |
+------------------+
1 row in set (0.10 sec)
```

### keywords
RANDOM, RAND
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,76 @@ specific language governing permissions and limitations
under the License.
-->

## pmod

## 描述

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

## 语法

```sql
BIGINT PMOD(BIGINT x, BIGINT y)
DOUBLE PMOD(DOUBLE x, DOUBLE y)
PMOD(<x> , <y>)
```
返回在模系下`x mod y`的最小正数解.
具体地来说, 返回 `(x%y+y)%y`.

## 参数

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

## 返回值

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

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

## 举例

```sql
SELECT PMOD(13,5);
```
MySQL [test]> SELECT PMOD(13,5);

```text
+-------------+
| pmod(13, 5) |
+-------------+
| 3 |
+-------------+
MySQL [test]> SELECT PMOD(-13,5);
+-------------+
```

```sql
SELECT PMOD(-13,5);
```

```text
+--------------+
| pmod(-13, 5) |
+-------------+
| 2 |
+-------------+
+--------------+
| 2 |
+--------------+
```

```sql
SELECT PMOD(0,-12);
```

```text
+--------------+
| pmod(0, -12) |
+--------------+
| 0 |
+--------------+
```

```sql
SELECT PMOD(0,null);
```

### keywords
PMOD
```text
+-------------------------------+
| pmod(cast(0 as DOUBLE), NULL) |
+-------------------------------+
| NULL |
+-------------------------------+
```
Loading
Loading