Why do Rationals promote to Floats

I think the reason is that

  1. calculations with eg Rational{Int64} would quickly overflow for the denominator,

  2. the results of transcendental functions (exp) cannot be a rational number in general.

So it is safest to promote to Float64. Of course, the trade-off is floating point inaccuracy.

Generally, I would just not promote but leave it to the operation. For a more specific workaround, please provide more context.

1 Like