note 26489 deleted from language.operators.arithmetic by sniper

From: Date: Mon, 13 Oct 2003 00:08:21 +0000
Subject: note 26489 deleted from language.operators.arithmetic by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58385@lists.php.net to get a copy of this message
Note Submitter: marsman at stack dot nl ---- Here the guy that reacted on 17-Jul-2002 04:14. As I said the algebra of my solution is simple, but why would a division like 10/2 give something like 4.99999? In this case my function can return this too when you execute something like div(11,2). It gives the correct answer because it represents the integer 5. But what if you give it to a function that expects an integer? I tried to write code that returns something like 4.9999999 and test it but I didn't succeed... what kind of division will result in this behaviour? Even when I litterally use the number 4.9999... with enough nines, it will actually be 5 (even with an integer typecast or floor). So I don't know how many nines would be in a result with the behaviour described, but couldn't it be that (int) and floor just works fine? example: floor(4.9999999999999999) results in 5 on my computer. I still think my solution is the most beautiful because it only uses integers (or floats that represent integers) for the results in between, but I can't think of an example in which the other solutions don't work.

« previous php.notes (#58385) next »