fmod() in PHP is the worst !”#¤%&/()= function ever!

I hate floating point artithmetic and I really hate fmod() in PHP. It’s useless.

fmodReturns the floating point remainder (modulo) of the division of the arguments

If you calculate 36 modulo 7.2?  What do you get? Zero, yes. 7.2*5=36. No remainder!

What if you use fmod in PHP?

$ php -r 'echo fmod(36,7.2);'

WTF? Excuse me? Is that the result from IEEE 754 hell, a parallel universe, or what?

Now I’m betting on the function below. I hope it won’t let me down.

function modulo($n,$b) {
return $n-$b*floor($n/$b);

Ubuntu upgrade behind firewall

I’m currently upgrading my Ubuntu-in-VirtualBox at work from Jaunty to Karmic, but at first it didn’t work at all. Update Manager got stuck when I clicked the “Upgrade” button.

Due to the Big Corporate Firewall all Internet access must go through the the Enterprisey Proxy so I immediately suspected a firewall/proxy issue. However, Update Manager, apt, etc have worked fine for a long time, so it must be something upgrade-specific.

Some debugging and googling led me to the url_downloadable ignores proxy settings bug report. Maybe I should have enabled jaunty-proposed but to get going I simply applied the attached patch and was able to get started with the upgrade.