base-4.6.0.1: Basic libraries

Portabilityportable
Stabilityexperimental
MaintainerAshley Yakeley <ashley@semantic.org>
Safe HaskellTrustworthy

Data.Fixed

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.

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

Synopsis

Documentation

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

generalisation of div to any instance of Real

mod' :: Real a => a -> a -> aSource

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

The type parameter should be an instance of HasResolution.

showFixed :: HasResolution a => Bool -> Fixed a -> StringSource

First arg is whether to chop off trailing zeros

type Uni = Fixed E0Source

resolution of 1, this works the same as Integer

type Deci = Fixed E1Source

resolution of 10^-1 = .1

type Centi = Fixed E2Source

resolution of 10^-2 = .01, useful for many monetary currencies

type Milli = Fixed E3Source

resolution of 10^-3 = .001

type Micro = Fixed E6Source

resolution of 10^-6 = .000001

type Nano = Fixed E9Source

resolution of 10^-9 = .000000001

type Pico = Fixed E12Source

resolution of 10^-12 = .000000000001