http://mbed.org/users/sam_grove/code/FP/#e0f19cdaa46e