Skip to content

Commit 468bc19

Browse files
authored
fix: convert native PHP floats to single precision (protocolbuffers#8187)
* fix: convert native PHP floats to single precision * fix unpack
1 parent 7165c34 commit 468bc19

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

php/src/Google/Protobuf/Internal/GPBUtil.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public static function checkUint64(&$var)
168168
public static function checkFloat(&$var)
169169
{
170170
if (is_float($var) || is_numeric($var)) {
171-
$var = floatval($var);
171+
$var = unpack("f", pack("f", $var))[1];
172172
} else {
173173
throw new \Exception("Expect float.");
174174
}

0 commit comments

Comments
 (0)