erlang examples
221V opened this issue · comments
1> io:format("~f~n", [0.1 + 0.2]).
0.300000
ok
2> io:format("~e~n", [0.1 + 0.2]).
3.00000e-1
Thanks for the suggestion! I'd be happy to merge it if you can submit it as a pull request.
also,
integers in js and php are floats,
and integers in erlang and haskell are not floats:
// js in latest firefox and chrome
103209823048320840000 + 1
103209823048320840000
103209823048320840000 + 20000
103209823048320860000
103209823048320840000 + 1 == 103209823048320840000
true
// php 7.3.5
echo (103209823048320840000 + 1);
echo "\n";
echo (103209823048320840000 + 20000);
echo "\n";
var_dump ((103209823048320840000 + 1) == 103209823048320840000);
//1.0320982304832E+20
//1.0320982304832E+20
//bool(true)
// erlang 22
1> 103209823048320840000 =:= (103209823048320840000 + 1).
false
// haskell -- ghc(i) 8.6.3
*Main> 103209823048320840000 == (103209823048320840000 + 1)
False
lol !!
upd. also erlang
1> io_lib:format("~.1f~n", [0.1 + 0.2]).
"0.3\n"
2> io_lib:format("~.2f~n", [0.1 + 0.2]).
"0.30\n"
also haskell -- ghc(i)
*Main> 0.1 + 0.2
0.30000000000000004
*Main> (0.1 + 0.2) :: Float
0.3
*Main> (0.1 + 0.2) :: Double
0.30000000000000004
(upd. sorry, you have haskell ghc example, i was not saw that ahaha)
ok, wait for pr )
Closed by #170