Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update readme and fix phpcs
  • Loading branch information
m3m0r7 committed Mar 4, 2019
commit 50786772b0ce6ff810b03291cad2360c8d4b7714
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,11 @@ public static void main(java.lang.String[])
- **LOCAL STORAGE** is showing stacked items on a method.

## PHP problems
- The PHP is cannot calculating big numbers because of PHP is different to the Java.
- **Problem 1:** The PHP is cannot calculating big numbers because of PHP is different to the Java.
But the PHPJava use `bcmath` functions and `gmp` functions to a certain extent to cover to calculate.
The PHPJava return valued is mixed why therefore We recommend to cast to `string` on the PHPJava.

- The PHPJava cannot cover to Java's types completely because of PHP is different to the Java.
- **Problem 2:** The PHPJava cannot cover to Java's types completely because of PHP is different to the Java.
The Java and the PHPJava comparison table is below.

|Java |PHPJava |
Expand All @@ -308,6 +308,9 @@ public static void main(java.lang.String[])
|float |\PHPJava\Kernel\Types\\_Float (including `__toString`), string, float |
|double |\PHPJava\Kernel\Types\\_Char (including `__toString`), string, float |

- **Problem 3:** PHPJava cannot calculate big numbered double and float values because of `gmp_pow` cannot calculate negative exponents.
So PHPJava use built-in functions which is `pow`.

## Run unit tests

- PHPUnit test is below.
Expand Down
3 changes: 1 addition & 2 deletions src/Utilities/BinaryTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ final public static function convertDoubleToIEEE754($doubleValue, $rounded = 8)
$bits = $doubleValue;
$s = ($bits >> 63) == 0 ? 1 : -1;
$e = ($bits >> 52) & 0x7ff;
$m = ($e == 0) ?
(($bits & 0xfffffffffffff) << 1) : ($bits & 0xfffffffffffff) | 0x10000000000000;
$m = ($e == 0) ? (($bits & 0xfffffffffffff) << 1) : ($bits & 0xfffffffffffff) | 0x10000000000000;
return $s * $m * pow(2, $e - 1075);
}

Expand Down