You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to [the PHP docs][php-int] there is a maximum integer value:
6
+
7
+
> The size of an `int` is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed).
8
+
> 64-bit platforms usually have a maximum value of about 9E18.
9
+
> PHP does not support unsigned `int`s.
10
+
11
+
In other words, PHP cannot express any number `2^63` or greater as an integer.
12
+
Some of the tests for this exercise require 64 bit integers (`2^64`) which is beyond the integer size limitation of PHP.
13
+
14
+
[PHP automatically converts][php-int-to-float]`int`s to `float`s, when the numbers get too big:
15
+
16
+
> If PHP encounters a number beyond the bounds of the `int` type, it will be interpreted as a `float` instead.
17
+
> Also, an operation which results in a number beyond the bounds of the `int` type will return a `float` instead.
18
+
19
+
But the `float` type [has limited precision][php-float-precision].
20
+
And King hates unprecision.
21
+
So King decided to expect the results of the calculations as a string which expresses the integer value, rather than expressing the answer as `int` or `float`.
22
+
And he wants integer calculations, not just a lazy conversion at the end.
23
+
24
+
Can you solve this by avoiding numbers that are larger than the language will allow directly?
25
+
And please don't use other PHP libraries like `gmp` or `bc`, too.
0 commit comments