Q:

Square Root of Rational

Given the following Rational:
Prelude> x
1 % 2

I tried to take its square root:
Prelude> sqrt x

<interactive>:14:1:
    No instance for (Floating Rational) arising from a use of `sqrt'
    In the expression: sqrt x
    In an equation for `it': it = sqrt x

I read this Math conversion article. But I did not see how to convert between Rational and Floating.
How can I do this?

A:

You can use either the fromRational,
fromRational :: Fractional a => Rational -> a

or the general-purpose realToFrac,
realToFrac :: (Real a, Fractional b) => a -> b

