Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Untitled notebook

b64_to_int_debezium.livemd

Untitled notebook

Mix.install([
  {:hexdump, "~> 0.1.4"}
])

Section

defmodule B64ToFloat do
  def to_float(b64) do
    b64
    |> Base.decode64!()
    |> decode_signed()
    |> Kernel./(100)
  end


  defp decode_signed(binary) do
    size = bit_size(binary)
    <> = binary
    value
  end
end

# 0, 855, -15,
Enum.map(["+iQ=", "AA==", "AU38", "+iQ="], &amp;B64ToFloat.to_float/1) |> Enum.join("\n") |> IO.puts()