unwitch-3.0.0: converts between primitives
Safe HaskellNone
LanguageHaskell2010

Unwitch.Convert.Fixed

Description

Conversions from Fixed.

Synopsis

Documentation

fromInteger :: HasResolution a => Integer -> Fixed a Source #

Converts an Integer to a Fixed value. Infallible.

toInteger :: HasResolution a => Fixed a -> Maybe Integer Source #

Converts a Fixed value to Integer, succeeding only if there is no fractional part (i.e. the value is a whole number).

toRational :: HasResolution a => Fixed a -> Rational Source #

Converts a Fixed value to Rational. Infallible, exact.

toFixed :: (HasResolution a, HasResolution b) => Fixed a -> Maybe (Fixed b) Source #

Converts between Fixed types with potentially different resolutions. Succeeds only if the value can be exactly represented in the target resolution.

toDouble :: HasResolution a => Fixed a -> Double Source #

Converts a Fixed value to Double. Infallible, but may lose precision for values that cannot be exactly represented as a Double.