base-4.7.0.2: Basic libraries

Copyright(c) Ashley Yakeley 2005, 2006, 2009
LicenseBSD-style (see the file libraries/base/LICENSE)
MaintainerAshley Yakeley <ashley@semantic.org>
Stabilityexperimental
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell2010

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 -> 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

newtype Fixed a Source

The type parameter should be an instance of HasResolution.

Constructors

MkFixed Integer

Since: 4.7.0.0

Instances

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

First arg is whether to chop off trailing zeros

data E0 Source

Instances

type Uni = Fixed E0 Source

resolution of 1, this works the same as Integer

data E1 Source

Instances

type Deci = Fixed E1 Source

resolution of 10^-1 = .1

data E2 Source

Instances

type Centi = Fixed E2 Source

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

data E3 Source

Instances

type Milli = Fixed E3 Source

resolution of 10^-3 = .001

data E6 Source

Instances

type Micro = Fixed E6 Source

resolution of 10^-6 = .000001

data E9 Source

Instances

type Nano = Fixed E9 Source

resolution of 10^-9 = .000000001

type Pico = Fixed E12 Source

resolution of 10^-12 = .000000000001