use explicit casts to avoid MS complaints about rounding