Fergal 0 Posted August 31, 2011 Report Share Posted August 31, 2011 When I run; $number = 4675.55555;$number = number_format ($number, 20); print $number; it outputs 4,675.55555000000003929017 Where do the extra "3929017" digits come from? Thanks! Quote Link to post Share on other sites
Larry 433 Posted August 31, 2011 Report Share Posted August 31, 2011 This is a common, although not widely known, aspect of computers: they don't store numbers cleanly. For example, in many languages, this condition would be false: (1/3 * 3) == 1 So internally, PHP is adding those extra digits (or, to be precise, the computer's architecture is). Quote Link to post Share on other sites
Fergal 0 Posted August 31, 2011 Author Report Share Posted August 31, 2011 Thanks Larry. I'm deliberately trying to break the scripts I write now and it has really helped my understanding of the book's content. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.