You are fine with double, unless you try doing some math with extreme values like adding 2000000BTC and 0.00000001BTC a few times, then you can hit some rounding errors.

Well exactly. Like you say, you can hit some rounding errors. And you don't want rounding errors, because they are errors. So you are

**not** "fine with a double". Financial math needs to be exact.

I use varchar(10) in my sql database for account balances

If you're using varchar, it's not sufficient to use varchar(10), which is not even enough to store a value of 12.12345678 bitcoins. Storage is cheap enough that you should use varchar(17), which can hold any number of bitcoins up to the maximum possible of 21000000.00000000.

If you're using numeric types, DECIMAL(16,8) will work perfectly.

You also need to use decimal-safe arithmetic in your PHP code. The "bcmath" and "gmp" libraries are decimal-safe math libraries for PHP.

Here's a reference to numeric types in MySQL:

http://dev.mysql.com/doc/refman/5.0/en/numeric-types.htmlFrom that page:

The DECIMAL and NUMERIC types store exact numeric data values. These types are used when it is important to preserve exact precision, for example with monetary data.