[erlang-questions] Strange float / tuple problem

Donald Steven t6sn7gt@REDACTED
Sat Jun 4 05:11:16 CEST 2016


Hi all,

I'm having a problem I don't understand.

I'm creating some X and Y coordinates in a program.  When I print them 
via:    io:format("~nX: ~f   Y: ~f ", [X,Y]),

I get:    X: 0.000000   Y: -5.000000

which is correct.

======

When I make a tuple of them, add them to a list and print them via:    
io:format("~nL: ~p~n", [L]),

I get:    {4.440892098500626e-16,-5.0},

which is very strange.  There are many other {X,Y} tuples in the list 
and all of them are correct, including earlier values of X which were 
also 0.0 and print correctly as 0.0.

=====

Your thoughts would be very welcome.

Thanks.

Don



More information about the erlang-questions mailing list