Skip to content

elm-toulouse/float16

Repository files navigation


Getting Started

Installation

elm install elm-toulouse/float16

Usage

import Bytes exposing (Bytes, Endianness(..))
import Bytes.Decode as D
import Bytes.Encode as E
import Bytes.Floating.Encode as E

-- ENCODER

encode : Float -> E.Encoder
encode f =
  E.sequence 
    [ E.float16 BE f
    , E.float32 BE f
    , E.float64 BE f
    ]

-- DECODER

decode : D.Decoder (Float, Float, Float)
decode =
  D.map3 (\a b c -> (a, b, c))
    |> D.float16 BE 
    |> D.float32 BE
    |> D.float64 BE

Changelog

CHANGELOG.md