tags:

views:

48

answers:

1

My last question leads me to this one:

wxTextCtrl:setValue( TcGrossProfit, io_lib:format("~.2f",[NewGrossProfit])),

generates an error from wxTextCtrl, with a bad arg.

I know this is the culprit

NewGrossProfit = 5.45333,

io_lib:format("~.2f",[NewGrossProfit])

Thanks for the last one, hope this one's easier

-B

EDIT

Last Question: http://stackoverflow.com/questions/4006201/truncate-a-float-in-erlang

+5  A: 

The problem is that io_lib:format("~.2f",[NewGrossProfit]) returns an iolist: ["5.45"], but wxTextCtrl:setValue seems to need a string ("5.45"). So

wxTextCtrl:setValue( TcGrossProfit, lists:flatten(io_lib:format("~.2f",[NewGrossProfit])))

should work.

Alexey Romanov
What about if my float is an exponential like: