Bug #79127 [Opn->Nab]: Giving wrong mod value for

From: Date: Thu, 16 Jan 2020 13:26:50 +0000
Subject: Bug #79127 [Opn->Nab]: Giving wrong mod value for
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224933@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79127&edit=1 ID: 79127 Updated by: cmb@php.net Reported by: dattatray dot gavade at encureit dot com Summary: Giving wrong mod value for -Status: Open +Status: Not a bug Type: Bug Package: *Math Functions Operating System: Windows 7 64 bit PHP Version: Irrelevant -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-01-16 12:44:21] dattatray dot gavade at encureit dot com Description: ------------ $amount = 40.12; $amount *= 100; $val = ($amount % 100); echo $val; This is showing mod as 11 instead of 12 Test script: --------------- $amount = 40.12; $amount *= 100; $val = ($amount % 100); echo $val; // showing 11 instead of 12 Expected result: ---------------- 12 Actual result: -------------- 11 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79127&edit=1

« previous php.bugs (#224933) next »