repa-scalar-4.2.3.3: Scalar data types and conversions.

Safe HaskellNone
LanguageHaskell98

Data.Repa.Scalar.Double

Contents

Description

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

Loading

loadDouble Source #

Arguments

:: 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.