| base-3.0.1.0: Basic libraries | Source code | Contents | Index

Data.Fixed |

Portability | portable
Stability | experimental
Maintainer | Ashley Yakeley <ashley@semantic.org>

Description
This module defines a "Fixed" type for fixed-precision arithmetic. The parameter to Fixed is any type that's an instance of HasResolution. HasResolution has a single method that gives the resolution of the Fixed type. Parameter types E6 and E12 (for 10^6 and 10^12) are defined, as well as type synonyms for Fixed E6 and Fixed E12.

This module also contains generalisations of div, mod, and divmod to work with any Real instance.

Synopsis

div' :: (Real a, Integral b) => a -> a -> b
mod' :: Real a => a -> a -> a
divMod' :: (Real a, Integral b) => a -> a -> (b, a)
data Fixed a
class HasResolution a where

resolution :: a -> Integer

showFixed :: HasResolution a => Bool -> Fixed a -> String
data E6
type Micro = Fixed E6
data E12
type Pico = Fixed E12

Documentation

div' :: (Real a, Integral b) => a -> a -> b | Source

generalisation of `div` to any instance of Real

mod' :: Real a => a -> a -> a | Source

generalisation of `mod` to any instance of Real

divMod' :: (Real a, Integral b) => a -> a -> (b, a) | Source

generalisation of `divMod` to any instance of Real

data Fixed a | Source

Instances

Enum (Fixed a)
Eq (Fixed a)
HasResolution a => Fractional (Fixed a)
HasResolution a => Num (Fixed a)
Ord (Fixed a)
HasResolution a => Real (Fixed a)
HasResolution a => RealFrac (Fixed a)
HasResolution a => Show (Fixed a)

class HasResolution a where | Source

Methods

resolution :: a -> Integer | Source

Instances

HasResolution E12
HasResolution E6

showFixed :: HasResolution a => Bool -> Fixed a -> String | Source

First arg is whether to chop off trailing zeros

data E6 | Source

Instances

HasResolution E6

type Micro = Fixed E6 | Source

data E12 | Source

Instances

HasResolution E12

type Pico = Fixed E12 | Source

Produced by Haddock version 0.8