The IEEE754 standard specifies how floating point numbers should be represented in binary form, and is the standard adopted by most programming languages.

In elixir, I just discovered today that floating point numbers can be easily converted to this representation.

binary16

 iex> <<0.000000059604645::float-16>>
<<0, 1>>

binary32

 iex> <<0.15625::float-32>>
<<62, 32, 0, 0>>

binary64

 iex> <<0.01171875::float-64>>
<<63, 136, 0, 0, 0, 0, 0, 0>>

appendix

https://en.wikipedia.org/wiki/IEEE_754

https://erlang-questions.erlang.narkive.com/v5FobBUc/float-to-ieee-754-single-and-double-representation


Ljzn
399 声望102 粉丝

网络安全;函数式编程;数字货币;人工智能