do some math operations as double to avoid overflow