Fergal Posted August 31, 2011 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! Link to comment Share on other sites More sharing options...
Larry Posted August 31, 2011 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). Link to comment Share on other sites More sharing options...
Fergal Posted August 31, 2011 Author 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. Link to comment Share on other sites More sharing options...
Recommended Posts