note 86708 deleted from function.round by googleguy

From: Date: Sun, 09 Dec 2012 08:22:23 +0000
Subject: note 86708 deleted from function.round by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-192414@lists.php.net to get a copy of this message
Note Submitter: Montoya ---- Here's a quick gotcha: I was fetching some data from a web service using cURL & SimpleXML and getting values like 28.75. I was then rounding these values but getting 28 instead of 29. Turns out the values were strings, so round() would treat them as integers, and casting to an int drops off the decimals (like floor()). So I had to do: round( (double) $val ); HTH!

« previous php.notes (#192414) next »