fraction-0.1.0.6: Fractions

Safe HaskellSafe
LanguageHaskell98

Data.Fraction

Contents

Description

This module is about fractions.

A fraction can be seen as a real number from the closed interval [0,1]. It can also be seen as a percentage. A typical example of a fraction is the extend of a progress bar.

Synopsis

Fraction type

Conversion

fromFactor :: Real real => real -> Fraction Source #

Converts a factor into its corresponding fraction.

If the factor is not from the interval [0,1], a runtime error occurs.

fromPercentage :: Real real => real -> Fraction Source #

Converts a percentage into its corresponding fraction.

If the percentage is not from the interval [0,100], a runtime error occurs.

fromNumber :: Real real => (real, real) -> real -> Fraction Source #

Converts a number into its corresponding fraction regarding a certain interval.

If the lower bound of the interval is equal to or greater than the upper bound or the value is not from the interval, a runtime error occurs.

toFactor :: Fraction -> Double Source #

Converts a fraction into its corresponding factor.

toPercentage :: Fraction -> Double Source #

Converts a fraction into its corresponding percentage.

toNumber :: (Double, Double) -> Fraction -> Double Source #

Converts a fraction into its corresponding number regarding a certain interval.

If the lower bound of the interval is equal to or greater than the upper bound, a runtime error occurs.