Skip to content

Commit

Permalink
fix: convert native PHP floats to single precision (#8187)
Browse files Browse the repository at this point in the history
* fix: convert native PHP floats to single precision

* fix unpack
  • Loading branch information
bshaffer committed Jan 11, 2021
1 parent 7165c34 commit 468bc19
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion php/src/Google/Protobuf/Internal/GPBUtil.php
Expand Up @@ -168,7 +168,7 @@ public static function checkUint64(&$var)
public static function checkFloat(&$var)
{
if (is_float($var) || is_numeric($var)) {
$var = floatval($var);
$var = unpack("f", pack("f", $var))[1];
} else {
throw new \Exception("Expect float.");
}
Expand Down

0 comments on commit 468bc19

Please sign in to comment.