OTP: erlang:list_to_float

Alexander Williams thantos@REDACTED
Thu May 12 11:34:27 CEST 2005


Thursday, May 12, 2005, 5:26:47 AM:

ML> According   to   the  draft  erlang  spec,  "3"  is  not  a  valid
ML> representation of a float literal. See section 3.12 of

ML>    http://www.erlang.org/download/erl_spec47.ps.gz

ML> I'm guessing that float_to_list/1 follows the same rules, and that
ML> doesn't seem so odd. I was a bit surprised that io_lib:fread("~f",
ML> "3") doesn't give me the float 3.0000, though.

  Rather annoying to run into purely unexpectedly when in the midst of
  hacking  of  some Yaws processing of data back from MySQL. ("Er, "3"
  is  a  badarg? Excuse me?") Nothing I couldn't hack around by simply
  searching the string for a "." and then appending ".0" if one wasn't
  found, but it was vaguely annoying to have to do so.

  It  almost  makes one long for a list_to_number generalized function
  that returns a float or int as appropriate to what it's handed, when
  you don't care about the result.

ML> While  on the subject of punctuation, you're missing the ':' after
ML> 'http' in your sig:

 >> The Squid's Redoubt: http//chancel.org:8000/Redoubt

  You  are  absolutely correct, sir, and the amusing bit is it must've
  been  like  that for a good 6mo now with me not noticing. [facepalm]
  Despite it being at the bottom of every email I send.

  There you go. Your good deed for the month. :)

 Alexander Williams  (thantos@REDACTED)
The Squid's Redoubt: http://chancel.org:8000/Redoubt
  Currently Playing: They Might Be Giants - Birdhouse In Your Soul
              Album: Flood

More information about the erlang-questions mailing list