Archive for March 2009

Comparing Big Numbers in PHP

Problem
What if I need to compare really big numbers in PHP? Like comparing 2^66 > 3^53?
Overview
This will work:

print (int) (pow(2,66) > pow(3,53));

PHP will convert the integers to scientific notation. But this script illustrates the limitation of normal operational syntax (i.e.: pow(2,66) > pow(3,53) vs. bccomp(bcpow(2,66), bcpow(3,53),1) > 0):

$max = 1000;
foreach ( range(1,$max) as [...]

Command Line Email on Ubuntu (mailx version)

This guide explains how to configure Ubuntu so that you can send email from the command line using mailx with your Gmail account for delivery. This updates a guide I originally posted on the ubuntu forums for mailx, which is part of the current Ubuntu repositories (versions 7 and 8). To use nail, [...]

Command Line Email on Ubuntu (nail version)

This will be the first of two posts showing you how to configure the more recent versions of Ubuntu to send email from the command line as simply as humanly possible using your Gmail account for delivery. These instructions were originally posted on my old blog and on the Ubuntu forums site.
This guide covers [...]