|
ContentsNumbersNumeric typesThe most important numeric type that are used by default are data Integer (Builtin) 32-bit signed integer data Double (Builtin) 64-bit floating point number SCL standard library defines also other integer and floating point number types: data Short (Builtin) 16-bit signed integer data Long (Builtin) 64-bit signed integer data Float (Builtin) 32-bit floating point number data BigInteger (BigInteger) Arbitrary-precision integer No automatic coercionSCL performs no implicit numeric conversion. Mixing
Use the explicit conversion functions Number literals are polymorphic and will satisfy any compatible numeric type, so writing
Dynamic type
Basic operations on numbers(+) :: Additive a => a -> a -> a (Prelude) Adds two objects (numbers, vectors, strings, etc.) together. (-) :: Ring a => a -> a -> a (Prelude) Subtraction neg :: Ring a => a -> a (Prelude) Negation. Synonym for unary (*) :: Ring a => a -> a -> a (Prelude) Multiplication (/) :: Real a => a -> a -> a (Prelude) Division (^) :: Real a => a -> a -> a (Prelude) Exponentation sqrt :: Real a => a -> a (Prelude) Square root exp :: Real a => a -> a (Prelude) Exponent function log :: Real a => a -> a (Prelude) Natural logarithm pi :: Real a => a (Prelude) Pi (3.141592654...) sin :: Real a => a -> a (Prelude) Sine cos :: Real a => a -> a (Prelude) Cosine tan :: Real a => a -> a (Prelude) Tangent asin :: Real a => a -> a (Prelude) Inverse sine acos :: Real a => a -> a (Prelude) Inverse cosine atan :: Real a => a -> a (Prelude) Inverse tangent. atan2 :: Real a => a -> a -> a (Prelude) Two parameter version of
When x > 0,
min :: Ord a => a -> a -> a (Prelude) Minimum of the parameters max :: Ord a => a -> a -> a (Prelude) Maximum of the parameters abs :: OrderedRing a => a -> a (Prelude) Absolute value. floor :: Real a => a -> a (Prelude) The largest integer not greater than the given number ceil :: Real a => a -> a (Prelude) The smallest integer not smaller than the given number div :: Integral a => a -> a -> a (Prelude) Integer division truncated toward zero. mod :: Integral a => a -> a -> a (Prelude) Integer remainder, satisfying Comparison
(!=) :: a -> a -> Boolean (Prelude) (<) :: Ord a => a -> a -> Boolean (Prelude) Less (<=) :: Ord a => a -> a -> Boolean (Prelude) Less or equal (>) :: Ord a => a -> a -> Boolean (Prelude) Greater (>=) :: Ord a => a -> a -> Boolean (Prelude) Greater or equal Conversion between numerical typesfromInteger :: Ring a => Integer -> a (Prelude) Converts an integer to a desired numeric type. toInteger :: OrderedRing a => a -> Integer (Prelude) Converts the given number to fromDouble :: Real a => Double -> a (Prelude) Converts a toDouble :: Real a => a -> Double (Prelude) Converts the given number to Numerical operations on listssum :: Additive a => [a] -> a (Prelude) Sum of the elements:
Implemented usually more efficiently than with repetitive
application of maximum :: Ord a => [a] -> a (Prelude) Maximum over a list minimum :: Ord a => [a] -> a (Prelude) Minimum over a list |