[PATCH] Explicitly convert type to double to avoid losing precision