hmt-base-0.20: Haskell Music Theory Base
Safe HaskellSafe-Inferred
LanguageHaskell2010

Music.Theory.Math.Convert

Description

Specialised type conversions, see mk/mk-convert.hs

map int_to_word8 [-1,0,255,256] == [255,0,255,0]
map int_to_word8_maybe [-1,0,255,256] == [Nothing,Just 0,Just 255,Nothing]
map integer_to_int64_maybe [-2 ^ 63 - 1,2 ^ 63] == [Nothing,Nothing]
map integer_to_word64_maybe [2 ^ 64 - 1,2 ^ 64] == [Just 18446744073709551615,Nothing]
map int16_to_float [-1,0,1] == [-1,0,1]
Synopsis

Numerical conversions

real_to_float :: Real t => t -> Float Source #

Type specialised realToFrac

real_to_double :: Real t => t -> Double Source #

Type specialised realToFrac

let n = sqrt (-1) in (n,real_to_double n)

double_to_int :: (Double -> Int) -> Double -> Int Source #

Type-specialise f, ie. round, ceiling, truncate

map (double_to_int round) [0, 0.25 .. 1] == [0, 0, 0, 1, 1]
map (double_to_int ceiling) [0, 0.25 .. 1] == [0, 1, 1, 1, 1]
map (double_to_int floor) [0, 0.25 .. 1] == [0, 0, 0, 0, 1]
map (double_to_int truncate) [0, 0.25 .. 1] == [0, 0, 0, 0, 1]

word8_to_int :: Word8 -> Int Source #

Type specialised fromIntegral

int8_to_int :: Int8 -> Int Source #

Type specialised fromIntegral

int16_to_int :: Int16 -> Int Source #

Type specialised fromIntegral

int32_to_int :: Int32 -> Int Source #

Type specialised fromIntegral

int64_to_int :: Int64 -> Int Source #

Type specialised fromIntegral

int_to_integral :: Integral i => Int -> i Source #

Type specialised fromIntegral

int_to_word8 :: Int -> Word8 Source #

Type specialised fromIntegral

int_to_int8 :: Int -> Int8 Source #

Type specialised fromIntegral

int_to_int16 :: Int -> Int16 Source #

Type specialised fromIntegral

int_to_int32 :: Int -> Int32 Source #

Type specialised fromIntegral

int_to_int64 :: Int -> Int64 Source #

Type specialised fromIntegral

int_to_float :: Int -> Float Source #

Type specialised fromIntegral