note 60793 added to function.intval

From: Date: Mon, 16 Jan 2006 21:21:54 +0000
Subject: note 60793 added to function.intval
Groups: php.notes 
Request: Send a blank email to php-notes+get-101941@lists.php.net to get a copy of this message
You guys are going to love this. I found something that I found quite disturbing. $test1 = intVal(1999); $amount = 19.99 * 100; $test2 = intVal($amount); $test3 = intVal("$amount"); echo $test1 . "<br />\n"; echo $test2 . "<br />\n"; echo $test3 . "<br />\n"; expected output: 1999 1999 1999 actual output 1999 1998 1999 Appears to be a floating point issue, but the number 1999 is the only number that I was able to get to do this. 19.99 is the price of many things, and for our purpose we must pass it as 1999 instead of 19.99. ---- Server IP: 217.160.72.57Probable Submitter: 66.213.226.42 ---- Manual Page -- http://www.php.net/manual/en/function.intval.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60793 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60793&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60793&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60793&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60793&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60793&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60793&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60793&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60793&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101941) next »