Skip to content

Commit ad4f8f4

Browse files
refactor: variable declarations in math functions
1 parent 5888102 commit ad4f8f4

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

src/Libs/Maths/Basic Math Functions.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Syntax :
1010
double x = Math.pow(2,3); // 8
1111
```
1212

13-
>[!TIP] Use `Math.pow(x,1/n)` to get nth root
13+
>[!TIP] Use <code>Math.pow(x , 1/n)</code> to get nth root
1414
1515
## sqrt()
1616
This method returns sqrt of the argument.
@@ -40,9 +40,9 @@ Return type : `double`
4040

4141
Syntax :
4242
```java
43-
double x = Math.ceil(6.1); // 7.0
44-
double x = Math.ceil(6); // 6.0
45-
double x = Math.ceil(-6.1); // -6.0
43+
double a = Math.ceil(6.1); // 7.0
44+
double b = Math.ceil(6); // 6.0
45+
double c = Math.ceil(-6.1); // -6.0
4646
```
4747

4848
## floor()
@@ -53,9 +53,9 @@ Return type : `double`
5353

5454
Syntax :
5555
```java
56-
double x = Math.floor(6.1); // 6.0
57-
double x = Math.floor(6); // 6.0
58-
double x = Math.floor(-6.1); // -7.0
56+
double a = Math.floor(6.1); // 6.0
57+
double b = Math.floor(6); // 6.0
58+
double c = Math.floor(-6.1); // -7.0
5959
```
6060

6161
## round()
@@ -65,11 +65,11 @@ Return type : `long` / `int`
6565

6666
Syntax :
6767
```java
68-
double x = Math.round(6.5); // 7
69-
double x = Math.round(6.4); // 6
70-
double x = Math.round(-6.5); // -6
71-
double x = Math.round(-6.4); // -6
72-
double x = Math.round(-2.6); // -3
68+
double a = Math.round(6.5); // 7
69+
double b = Math.round(6.4); // 6
70+
double c = Math.round(-6.5); // -6
71+
double d = Math.round(-6.4); // -6
72+
double e = Math.round(-2.6); // -3
7373
```
7474
7575
>[!TIP] Note the above syntax carefully. ( .5 round up is done in case of positive values and .6 round down is done in case of negative numbers.)
@@ -81,10 +81,10 @@ Return type : `double` / `float` / `int` / `long` (same as argument datatype)
8181

8282
Syntax :
8383
```java
84-
double x = Math.abs(6.5); // 6.5
85-
double x = Math.abs(-6.5); // 6.5
86-
double x = Math.abs(-6); // 6
87-
double x = Math.abs(6); // 6
84+
double a = Math.abs(6.5); // 6.5
85+
double b = Math.abs(-6.5); // 6.5
86+
double c = Math.abs(-6); // 6
87+
double d = Math.abs(6); // 6
8888
```
8989
9090

@@ -96,7 +96,7 @@ Return type : `double` / `float` / `int` / `long` (same as argument datatype)
9696
Syntax :
9797
```java
9898
double x = Math.max(6.5, 6.4); // 6.5
99-
double x = Math.max(-2 , -3); // -2
99+
double y = Math.max(-2 , -3); // -2
100100
```
101101

102102
## min()
@@ -107,7 +107,7 @@ Return type : `double` / `float` / `int` / `long` (same as argument datatype)
107107
Syntax :
108108
```java
109109
double x = Math.min(6.5, 6.4); // 6.4
110-
double x = Math.min(-2 , -3); // -3
110+
double y = Math.min(-2 , -3); // -3
111111
```
112112

113113
## random()
@@ -118,12 +118,12 @@ Return type : `double`
118118
Syntax :
119119
```java
120120
double x = Math.random(); // 0.1358...
121-
double x = Math.random(); // 0.0
121+
double y = Math.random(); // 0.0
122122
```
123123

124124
<br>
125125

126126
>[!WARNING] Math.PI
127127
>Java stores pi as a constant in the Math class.
128128
>>[!NOTE] Syntax :
129-
>>`double pi = Math.PI();`
129+
>>`double pi = Math.PI();`

0 commit comments

Comments
 (0)