Safe Haskell | None |
---|---|
Language | Haskell98 |
Loading and storing doubles directly from/to memory buffers.
- Calls out to foreign load and store functions written in C and C++, so performance should be alright.
Synopsis
- loadDouble :: Ptr Word8 -> Int -> IO (Double, Int)
- storeDoubleShortest :: Double -> IO (ForeignPtr Word8, Int)
- storeDoubleFixed :: Int -> Double -> IO (ForeignPtr Word8, Int)
Loading
:: Ptr Word8 | Buffer holding ASCII representation. |
-> Int | Length of buffer. |
-> IO (Double, Int) | Result, and number of characters read from buffer. |
Load an ASCII Double
from a foreign buffer
returning the value and number of characters read.
- Calls out do the stdlib
strtod
function.
Storing
storeDoubleShortest :: Double -> IO (ForeignPtr Word8, Int) Source #
Store an ASCII Double
, yielding a freshly allocated buffer
and its length.
- Calls out to the `double-conversion` library which is binding to a C++ implementation.
- The value is printed as either (sign)digits.digits, or in exponential format, depending on which is shorter.
- The result is buffer not null terminated.
storeDoubleFixed :: Int -> Double -> IO (ForeignPtr Word8, Int) Source #
Like showDoubleShortest
, but use a fixed number of digits after
the decimal point.