Skip to content

Commit e290b83

Browse files
authored
Merge pull request brianleroux#139 from ionpot/master
Two Special Numbers
2 parents 02afd7f + 4ae9954 commit e290b83

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
There seems to be a number that fulfills all of these conditions:
2+
3+
```
4+
i * i = 0
5+
i + 1 = 1
6+
i - 1 = -1
7+
i / i = 1
8+
```
9+
10+
Turns out that this magical number is not even an integer:
11+
12+
```
13+
i = Number.MIN_VALUE
14+
```
15+
16+
It's the smallest possible fraction JavaScript can produce, and is treated as zero for the most part.
17+
18+
Conversely, the largest possible fraction claims to be greater than one, but reduces to zero:
19+
20+
```
21+
i = Number.MAX_VALUE
22+
23+
i > 1 // true
24+
i|0 // 0
25+
```
26+
27+
Furthermore, both the largest possible fraction and integer refuse to wrap around:
28+
29+
```
30+
i = Number.MAX_VALUE
31+
j = 0xffffffffffffffff
32+
33+
i === (i + 1) // true
34+
j === (j + 1) // true
35+
```
36+
37+
- [@ionpot](https://github.com/ionpot)

0 commit comments

Comments
 (0)