Bug #80241 [Opn->Nab]: Casts double to int

From: Date: Thu, 15 Oct 2020 14:33:35 +0000
Subject: Bug #80241 [Opn->Nab]: Casts double to int
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229647@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80241&edit=1 ID: 80241 Updated by: girgias@php.net Reported by: dmitrijlin9 at gmail dot com Summary: Casts double to int -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Windows 10 PHP Version: 7.4.11 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-10-15 14:30:35] dmitrijlin9 at gmail dot com Description: ------------ I'm trying to cast double variable to int, but i have wrong answer Test script: --------------- $a = '2166.99'; echo (int)($a *100); Expected result: ---------------- 216699 Actual result: -------------- 216698 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80241&edit=1

« previous php.bugs (#229647) next »