From 5279b3af4efee5d3e7d9755f0f06bd7b0f5dd05c Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Fri, 8 Feb 2013 18:23:22 +0100 Subject: Add float_to_binary and binary_to_float --- erts/doc/src/erlang.xml | 53 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 14 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml index 36d606130f..06fefa8efb 100644 --- a/erts/doc/src/erlang.xml +++ b/erts/doc/src/erlang.xml @@ -299,6 +299,18 @@

Failure: badarg if the atom does not already exist.

+ + + Convert from text representation to a float + +

Returns the float whose text representation is Binary.

+
+> binary_to_float(<<"2.2017764e+0">>).
+2.2017764
+

Failure: badarg if Binary contains a bad + representation of a float.

+
+
Convert from text representation to an integer @@ -987,26 +999,38 @@ true - + Text representation of a float -

Returns a string which corresponds to the text - representation of Float.

+

The same as float_to_binary(Float,[{scientific,20}]).

+
+
+ + + Text representation of a float formatted using given options + +

Returns a binary which corresponds to the text + representation of Float using fixed decimal + point formatting. The Options behave in the same + way as float_to_list/2. +

-> float_to_list(7.0).
-"7.00000000000000000000e+00"
+> float_to_binary(7.12, [{decimals, 4}]). +<<"7.1200">> +> float_to_binary(7.12, [{decimals, 4}, compact]). +<<"7.12">> +
+
+ + + Text representation of a float + +

The same as float_to_list(Float,[{scientific,20}]).

- float_to_list(Float, Options) -> string() + Text representation of a float formatted using given options - - Float = float() - Options = [Option] - Option = {decimals, Decimals::0..253} | - {scientific, Decimals::0..249} | - compact -

Returns a string which corresponds to the text representation of Float using fixed decimal point formatting. @@ -1019,7 +1043,8 @@ true only meaningful together with the decimals option). When scientific option is provided, the float will be formatted using scientific notation with Decimals digits of precision. If - Options is [] the function behaves like float_to_list/1. + Options is [] the function behaves like + float_to_list/1.

 > float_to_list(7.12, [{decimals, 4}]).
-- 
cgit v1.2.3