mattiabasone commented on code in PR #3526:
URL: https://github.com/apache/avro/pull/3526#discussion_r2454712978


##########
lang/php/lib/Datum/AvroIOBinaryEncoder.php:
##########
@@ -187,4 +188,46 @@ public function writeBytes($bytes)
         $this->writeLong(strlen($bytes));
         $this->write($bytes);
     }
+
+    public function writeDecimal($decimal, int $scale, int $precision): void
+    {
+        if (!is_numeric($decimal)) {
+            throw new AvroException('Decimal must be a numeric value');
+        }
+
+        $value = $decimal * (10 ** $scale);
+        if (!is_int($value)) {
+            $value = (int) round($value);
+        }
+        if (abs($value) > (10 ** $precision - 1)) {

Review Comment:
   Isn't this the same check with only the sign changed (from > to >=)?
   The value is already scaled some lines before.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to