hosc-0.21.1: Haskell Open Sound Control

Safe Haskell | None
Language | Haskell2010

Sound.Osc.Coding.Cast

Description

Bit-level type casts and byte layout string typecasts.

Synopsis

- f32_w32 :: Float -> Word32
- w32_f32 :: Word32 -> Float
- f64_w64 :: Double -> Word64
- w64_f64 :: Word64 -> Double
- str_cstr :: String -> [Word8]
- cstr_str :: [Word8] -> String
- str_pstr :: String -> [Word8]
- pstr_str :: [Word8] -> String

# Documentation

f32_w32 :: Float -> Word32 Source #

The IEEE byte representation of a float.

    >>> f32_w32 pi
    1078530011

    >>> f32_w32 (-7913907.5)
    3404825447

    >>> 23 ^ 7
    3404825447

w32_f32 :: Word32 -> Float Source #

Inverse of `f32_w32`.

    >>> w32_f32 1078530011
    3.1415927

    >>> w32_f32 (23 ^ 7)
    -7913907.5

f64_w64 :: Double -> Word64 Source #

The IEEE byte representation of a double.

    >>> f64_w64 pi
    4614256656552045848

    >>> f64_w64 1.6822072834e-314
    3404825447

w64_f64 :: Word64 -> Double Source #

Inverse of `f64_w64`.

    >>> w64_f64 4614256656552045848
    3.141592653589793

    >>> w64_f64 (23 ^ 7)
    1.6822072834e-314

str_cstr :: String -> [Word8] Source #

Transform a haskell string into a C string (a null suffixed byte string).

cstr_str :: [Word8] -> String Source #

Inverse of `str_cstr`.

str_pstr :: String -> [Word8] Source #

Transform a haskell string to a pascal string (a length prefixed byte string).

pstr_str :: [Word8] -> String Source #

Inverse of `str_pstr`.