0
# Numeric Operations
1
2
Mathematical validation functions for number properties, comparisons, and arithmetic checks.
3
4
## Capabilities
5
6
### Number Properties
7
8
#### Even Check
9
10
Checks if the given number is even.
11
12
```javascript { .api }
13
/**
14
* Checks if the given value is even
15
* @param n - Number to check
16
* @returns True if number is even
17
* Interfaces: not, all, any
18
*/
19
function even(n: number): boolean;
20
```
21
22
**Usage Example:**
23
24
```javascript
25
is.even(42); // true
26
is.not.even(41); // true
27
is.all.even(40, 42, 44); // true
28
is.any.even(39, 42, 43); // true
29
```
30
31
#### Odd Check
32
33
Checks if the given number is odd.
34
35
```javascript { .api }
36
/**
37
* Checks if the given value is odd
38
* @param n - Number to check
39
* @returns True if number is odd
40
* Interfaces: not, all, any
41
*/
42
function odd(n: number): boolean;
43
```
44
45
**Usage Example:**
46
47
```javascript
48
is.odd(41); // true
49
is.not.odd(42); // true
50
is.all.odd(39, 41, 43); // true
51
is.any.odd(39, 42, 44); // true
52
```
53
54
#### Positive Check
55
56
Checks if the given number is positive.
57
58
```javascript { .api }
59
/**
60
* Checks if the given value is positive
61
* @param n - Number to check
62
* @returns True if number is positive
63
* Interfaces: not, all, any
64
*/
65
function positive(n: number): boolean;
66
```
67
68
**Usage Example:**
69
70
```javascript
71
is.positive(41); // true
72
is.not.positive(-42); // true
73
is.all.positive(39, 41, 43); // true
74
is.any.positive(-39, 42, -44); // true
75
```
76
77
#### Negative Check
78
79
Checks if the given number is negative.
80
81
```javascript { .api }
82
/**
83
* Checks if the given value is negative
84
* @param n - Number to check
85
* @returns True if number is negative
86
* Interfaces: not, all, any
87
*/
88
function negative(n: number): boolean;
89
```
90
91
**Usage Example:**
92
93
```javascript
94
is.negative(-41); // true
95
is.not.negative(42); // true
96
is.all.negative(-39, -41, -43); // true
97
is.any.negative(-39, 42, 44); // true
98
```
99
100
#### Decimal Check
101
102
Checks if the given number is decimal (has fractional part).
103
104
```javascript { .api }
105
/**
106
* Checks if the given value is decimal
107
* @param n - Number to check
108
* @returns True if number is decimal
109
* Interfaces: not, all, any
110
*/
111
function decimal(n: number): boolean;
112
```
113
114
**Usage Example:**
115
116
```javascript
117
is.decimal(41.5); // true
118
is.not.decimal(42); // true
119
is.all.decimal(39.5, 41.5, -43.5); // true
120
is.any.decimal(-39, 42.5, 44); // true
121
```
122
123
#### Integer Check
124
125
Checks if the given number is an integer.
126
127
```javascript { .api }
128
/**
129
* Checks if the given value is integer
130
* @param n - Number to check
131
* @returns True if number is integer
132
* Interfaces: not, all, any
133
*/
134
function integer(n: number): boolean;
135
```
136
137
**Usage Example:**
138
139
```javascript
140
is.integer(41); // true
141
is.not.integer(42.5); // true
142
is.all.integer(39, 41, -43); // true
143
is.any.integer(-39, 42.5, 44); // true
144
```
145
146
#### Finite Check
147
148
Checks if the given number is finite.
149
150
```javascript { .api }
151
/**
152
* Checks if the given value is finite
153
* @param n - Number to check
154
* @returns True if number is finite
155
* Interfaces: not, all, any
156
*/
157
function finite(n: number): boolean;
158
```
159
160
**Usage Example:**
161
162
```javascript
163
is.finite(41); // true
164
is.not.finite(42 / 0); // true
165
is.all.finite(39, 41, -43); // true
166
is.any.finite(-39, Infinity, 44); // true
167
```
168
169
#### Infinite Check
170
171
Checks if the given number is infinite.
172
173
```javascript { .api }
174
/**
175
* Checks if the given value is infinite
176
* @param n - Number to check
177
* @returns True if number is infinite
178
* Interfaces: not, all, any
179
*/
180
function infinite(n: number): boolean;
181
```
182
183
**Usage Example:**
184
185
```javascript
186
is.infinite(Infinity); // true
187
is.not.infinite(42); // true
188
is.all.infinite(Infinity, -Infinity, -43 / 0); // true
189
is.any.infinite(-39, Infinity, 44); // true
190
```
191
192
### Number Comparisons
193
194
#### Above Check
195
196
Checks if the given number is above a minimum value.
197
198
```javascript { .api }
199
/**
200
* Checks if the given value is above minimum value
201
* @param n - Number to check
202
* @param min - Minimum value
203
* @returns True if number is above minimum
204
* Interfaces: not
205
*/
206
function above(n: number, min: number): boolean;
207
```
208
209
**Usage Example:**
210
211
```javascript
212
is.above(41, 30); // true
213
is.not.above(42, 50); // true
214
```
215
216
#### Under Check
217
218
Checks if the given number is under a maximum value.
219
220
```javascript { .api }
221
/**
222
* Checks if the given value is under maximum value
223
* @param n - Number to check
224
* @param max - Maximum value
225
* @returns True if number is under maximum
226
* Interfaces: not
227
*/
228
function under(n: number, max: number): boolean;
229
```
230
231
**Usage Example:**
232
233
```javascript
234
is.under(30, 35); // true
235
is.not.under(42, 30); // true
236
```
237
238
#### Within Check
239
240
Checks if the given number is within a range.
241
242
```javascript { .api }
243
/**
244
* Checks if the given value is within minimum and maximum values
245
* @param n - Number to check
246
* @param min - Minimum value (exclusive)
247
* @param max - Maximum value (exclusive)
248
* @returns True if number is within range
249
* Interfaces: not
250
*/
251
function within(n: number, min: number, max: number): boolean;
252
```
253
254
**Usage Example:**
255
256
```javascript
257
is.within(30, 20, 40); // true
258
is.not.within(40, 30, 35); // true
259
```
260
261
#### Equal Check
262
263
Checks if the given values are equal (handles special cases like 0/-0 and regex comparison).
264
265
```javascript { .api }
266
/**
267
* Checks if the given values are equal
268
* @param value - First value
269
* @param other - Second value
270
* @returns True if values are equal
271
* Interfaces: not
272
*/
273
function equal(value: any, other: any): boolean;
274
```
275
276
**Usage Example:**
277
278
```javascript
279
is.equal(42, 40 + 2); // true
280
is.equal('yeap', 'yeap'); // true
281
is.equal(true, true); // true
282
is.not.equal('yeap', 'nope'); // true
283
```