Bug #80144 [Opn->Nab]: if you go to do the sum is 0, but php returns 3.3306690738755E-15. Why?

From: Date: Thu, 24 Sep 2020 08:49:28 +0000
Subject: Bug #80144 [Opn->Nab]: if you go to do the sum is 0, but php returns 3.3306690738755E-15. Why?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229197@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80144&edit=1 ID: 80144 Updated by: cmb@php.net Reported by: daniel dot maoloni at gmail dot com Summary: if you go to do the sum is 0, but php returns 3.3306690738755E-15. Why? -Status: Open +Status: Not a bug Type: Bug Package: *Math Functions Operating System: Windows 10 Pro - XAMMP PHP Version: 7.4.10 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Floating point values have a limited precision. Hence a value might not have the same string representation after any processing. That also includes writing a floating point value in your script and directly printing it without any mathematical operations. If you would like to know more about "floats" and what IEEE 754 is, read this: http://www.floating-point-gui.de/ Thank you for your interest in PHP. Previous Comments: ------------------------------------------------------------------------ [2020-09-24 08:43:22] daniel dot maoloni at gmail dot com Description: ------------ $a=33.460000; $b=-34.870000; $c=1.410000; echo $a+$b+$c; result PHP : 3.3306690738755E-15 if you go to do the sum is 0, but php returns 3.3306690738755E-15. Why? thank you Test script: --------------- $a=33.460000; $b=-34.870000; $c=1.410000; echo $a+$b+$c; ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80144&edit=1

« previous php.bugs (#229197) next »