Doing the computation in cents would be one approach, or if you can tolerate float in the first place, perhaps double will suffice.