Movatterモバイル変換


[0]ホーム

URL:


base-4.12.0.0: Basic libraries

Copyright(c) The University of Glasgow 2002
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityprovisional
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell2010

Numeric

Contents

Description

Odds and ends, mostly functions for reading and showingRealFloat-like kind of values.

Synopsis

Showing

showSignedSource#

Arguments

::Real a 
=> (a ->ShowS)

a function that can show unsigned values

->Int

the precedence of the enclosing context

-> a

the value to show

->ShowS 

Converts a possibly-negativeReal value to a string.

showIntAtBase :: (Integral a,Show a) => a -> (Int ->Char) -> a ->ShowSSource#

Shows anon-negativeIntegral number using the base specified by the first argument, and the character representation specified by the second.

showInt ::Integral a => a ->ShowSSource#

Shownon-negativeIntegral numbers in base 10.

showHex :: (Integral a,Show a) => a ->ShowSSource#

Shownon-negativeIntegral numbers in base 16.

showOct :: (Integral a,Show a) => a ->ShowSSource#

Shownon-negativeIntegral numbers in base 8.

showEFloat ::RealFloat a =>MaybeInt -> a ->ShowSSource#

Show a signedRealFloat value using scientific (exponential) notation (e.g.2.45e2,1.5e-3).

In the callshowEFloat digs val, ifdigs isNothing, the value is shown to full precision; ifdigs isJust d, then at mostd digits after the decimal point are shown.

showFFloat ::RealFloat a =>MaybeInt -> a ->ShowSSource#

Show a signedRealFloat value using standard decimal notation (e.g.245000,0.0015).

In the callshowFFloat digs val, ifdigs isNothing, the value is shown to full precision; ifdigs isJust d, then at mostd digits after the decimal point are shown.

showGFloat ::RealFloat a =>MaybeInt -> a ->ShowSSource#

Show a signedRealFloat value using standard decimal notation for arguments whose absolute value lies between0.1 and9,999,999, and scientific notation otherwise.

In the callshowGFloat digs val, ifdigs isNothing, the value is shown to full precision; ifdigs isJust d, then at mostd digits after the decimal point are shown.

showFFloatAlt ::RealFloat a =>MaybeInt -> a ->ShowSSource#

Show a signedRealFloat value using standard decimal notation (e.g.245000,0.0015).

This behaves asshowFFloat, except that a decimal point is always guaranteed, even if not needed.

Since: 4.7.0.0

showGFloatAlt ::RealFloat a =>MaybeInt -> a ->ShowSSource#

Show a signedRealFloat value using standard decimal notation for arguments whose absolute value lies between0.1 and9,999,999, and scientific notation otherwise.

This behaves asshowFFloat, except that a decimal point is always guaranteed, even if not needed.

Since: 4.7.0.0

showFloat ::RealFloat a => a ->ShowSSource#

Show a signedRealFloat value to full precision using standard decimal notation for arguments whose absolute value lies between0.1 and9,999,999, and scientific notation otherwise.

showHFloat ::RealFloat a => a ->ShowSSource#

Show a floating-point value in the hexadecimal format,similar to the%a specifier in C's printf.

>>>showHFloat (212.21 :: Double) """0x1.a86b851eb851fp7">>>showHFloat (-12.76 :: Float) """-0x1.9851ecp3">>>showHFloat (-0 :: Double) """-0x0p+0"

floatToDigits ::RealFloat a =>Integer -> a -> ([Int],Int)Source#

floatToDigits takes a base and a non-negativeRealFloat number, and returns a list of digits and an exponent. In particular, ifx>=0, and

floatToDigits base x = ([d1,d2,...,dn], e)

then

  1. n >= 1
  2. x = 0.d1d2...dn * (base**e)
  3. 0 <= di <= base-1

Reading

NB:readInt is the 'dual' ofshowIntAtBase, andreadDec is the `dual' ofshowInt. The inconsistent naming is a historical accident.

readSigned ::Real a =>ReadS a ->ReadS aSource#

Reads asignedReal value, given a reader for an unsigned value.

readIntSource#

Arguments

::Num a 
=> a

the base

-> (Char ->Bool)

a predicate distinguishing valid digits in this base

-> (Char ->Int)

a function converting a valid digit character to anInt

->ReadS a 

Reads anunsignedIntegral value in an arbitrary base.

readDec :: (Eq a,Num a) =>ReadS aSource#

Read an unsigned number in decimal notation.

>>>readDec "0644"[(644,"")]

readOct :: (Eq a,Num a) =>ReadS aSource#

Read an unsigned number in octal notation.

>>>readOct "0644"[(420,"")]

readHex :: (Eq a,Num a) =>ReadS aSource#

Read an unsigned number in hexadecimal notation. Both upper or lower case letters are allowed.

>>>readHex "deadbeef"[(3735928559,"")]

readFloat ::RealFrac a =>ReadS aSource#

Reads anunsignedRealFrac value, expressed in decimal scientific notation.

lexDigits ::ReadSStringSource#

Reads a non-empty string of decimal digits.

Miscellaneous

fromRat ::RealFloat a =>Rational -> aSource#

Converts aRational value into any type in classRealFloat.

classFractional a =>Floating awhereSource#

Trigonometric and hyperbolic functions and related functions.

The Haskell Report defines no laws forFloating. However, '(+)', '(*)' andexp are customarily expected to define an exponential field and have the following properties:

  • exp (a + b) = @exp a * exp b
  • exp (fromInteger 0) =fromInteger 1

Minimal complete definition

pi,exp,log,sin,cos,asin,acos,atan,sinh,cosh,asinh,acosh,atanh

Methods

pi :: aSource#

exp :: a -> aSource#

log :: a -> aSource#

sqrt :: a -> aSource#

(**) :: a -> a -> ainfixr 8Source#

logBase :: a -> a -> aSource#

sin :: a -> aSource#

cos :: a -> aSource#

tan :: a -> aSource#

asin :: a -> aSource#

acos :: a -> aSource#

atan :: a -> aSource#

sinh :: a -> aSource#

cosh :: a -> aSource#

tanh :: a -> aSource#

asinh :: a -> aSource#

acosh :: a -> aSource#

atanh :: a -> aSource#

log1p :: a -> aSource#

log1p x computeslog (1 + x), but provides more precise results for small (absolute) values ofx if possible.

Since: 4.9.0.0

expm1 :: a -> aSource#

expm1 x computesexp x - 1, but provides more precise results for small (absolute) values ofx if possible.

Since: 4.9.0.0

log1pexp :: a -> aSource#

log1pexp x computeslog (1 +exp x), but provides more precise results if possible.

Examples:

  • ifx is a large negative number,log (1 +exp x) will be imprecise for the reasons given inlog1p.
  • ifexp x is close to-1,log (1 +exp x) will be imprecise for the reasons given inexpm1.

Since: 4.9.0.0

log1mexp :: a -> aSource#

log1mexp x computeslog (1 -exp x), but provides more precise results if possible.

Examples:

  • ifx is a large negative number,log (1 -exp x) will be imprecise for the reasons given inlog1p.
  • ifexp x is close to1,log (1 -exp x) will be imprecise for the reasons given inexpm1.

Since: 4.9.0.0

Instances
FloatingDoubleSource#

Since: 2.1

Instance details

Defined inGHC.Float

FloatingFloatSource#

Since: 2.1

Instance details

Defined inGHC.Float

FloatingCDoubleSource# 
Instance details

Defined inForeign.C.Types

FloatingCFloatSource# 
Instance details

Defined inForeign.C.Types

Floating a =>Floating (Identity a)Source#

Since: 4.9.0.0

Instance details

Defined inData.Functor.Identity

Methods

pi ::Identity aSource#

exp ::Identity a ->Identity aSource#

log ::Identity a ->Identity aSource#

sqrt ::Identity a ->Identity aSource#

(**) ::Identity a ->Identity a ->Identity aSource#

logBase ::Identity a ->Identity a ->Identity aSource#

sin ::Identity a ->Identity aSource#

cos ::Identity a ->Identity aSource#

tan ::Identity a ->Identity aSource#

asin ::Identity a ->Identity aSource#

acos ::Identity a ->Identity aSource#

atan ::Identity a ->Identity aSource#

sinh ::Identity a ->Identity aSource#

cosh ::Identity a ->Identity aSource#

tanh ::Identity a ->Identity aSource#

asinh ::Identity a ->Identity aSource#

acosh ::Identity a ->Identity aSource#

atanh ::Identity a ->Identity aSource#

log1p ::Identity a ->Identity aSource#

expm1 ::Identity a ->Identity aSource#

log1pexp ::Identity a ->Identity aSource#

log1mexp ::Identity a ->Identity aSource#

RealFloat a =>Floating (Complex a)Source#

Since: 2.1

Instance details

Defined inData.Complex

Floating a =>Floating (Op a b)Source# 
Instance details

Defined inData.Functor.Contravariant

Methods

pi ::Op a bSource#

exp ::Op a b ->Op a bSource#

log ::Op a b ->Op a bSource#

sqrt ::Op a b ->Op a bSource#

(**) ::Op a b ->Op a b ->Op a bSource#

logBase ::Op a b ->Op a b ->Op a bSource#

sin ::Op a b ->Op a bSource#

cos ::Op a b ->Op a bSource#

tan ::Op a b ->Op a bSource#

asin ::Op a b ->Op a bSource#

acos ::Op a b ->Op a bSource#

atan ::Op a b ->Op a bSource#

sinh ::Op a b ->Op a bSource#

cosh ::Op a b ->Op a bSource#

tanh ::Op a b ->Op a bSource#

asinh ::Op a b ->Op a bSource#

acosh ::Op a b ->Op a bSource#

atanh ::Op a b ->Op a bSource#

log1p ::Op a b ->Op a bSource#

expm1 ::Op a b ->Op a bSource#

log1pexp ::Op a b ->Op a bSource#

log1mexp ::Op a b ->Op a bSource#

Floating a =>Floating (Const a b)Source#

Since: 4.9.0.0

Instance details

Defined inData.Functor.Const

Methods

pi ::Const a bSource#

exp ::Const a b ->Const a bSource#

log ::Const a b ->Const a bSource#

sqrt ::Const a b ->Const a bSource#

(**) ::Const a b ->Const a b ->Const a bSource#

logBase ::Const a b ->Const a b ->Const a bSource#

sin ::Const a b ->Const a bSource#

cos ::Const a b ->Const a bSource#

tan ::Const a b ->Const a bSource#

asin ::Const a b ->Const a bSource#

acos ::Const a b ->Const a bSource#

atan ::Const a b ->Const a bSource#

sinh ::Const a b ->Const a bSource#

cosh ::Const a b ->Const a bSource#

tanh ::Const a b ->Const a bSource#

asinh ::Const a b ->Const a bSource#

acosh ::Const a b ->Const a bSource#

atanh ::Const a b ->Const a bSource#

log1p ::Const a b ->Const a bSource#

expm1 ::Const a b ->Const a bSource#

log1pexp ::Const a b ->Const a bSource#

log1mexp ::Const a b ->Const a bSource#

Produced byHaddock version 2.20.0


[8]ページ先頭

©2009-2025 Movatter.jp