I am using a function to create a list from a float.
float_to_list(0.02).
It returns:
"2.00000000000000000000e-002"
I need it to give me a number exactly like:
"0.20"
If I fed it 5.23
"5.23"
If I fed it 5.5
"5.50"
So basically the number rounded to two decimal places. Probably an easy fix.
Thanks
EDIT:
I would like to use the io format it looks like it might work,
but it dosen't in this example:
wxTextCtrl:setValue( TcGrossProfit, io:format("~p", [NUMBER]), ),
seems textctrl wants a string, I don't want to print it to the screen.
Alternatively you could use the function you were already using.
float_to_list(0.02,[{decimals, 2}])
outputs '0.02'
Or for Elixir users ;)
:erlang.float_to_list(5.231,[{:decimals, 2}])
outputs '5.2'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With