OTP: erlang:list_to_float

Alexander Williams thantos@REDACTED
Thu May 12 23:53:11 CEST 2005


Rich:

RN> I haven't used MySQL in a while, but isn't there a way to have the
RN> query format the data so it always has the decimal point? Granted,
RN> this  means  you're  converting the result to a string in order to
RN> format  it.  But  it  looks  as  though you're converting a string
RN> anyways.

  The  way  the mysql module for Erlang I'm using hands back data puts
  all  data  into  strings.  The  value  we're  talking  about here is
  declared  as a float in the SQL, but, apparently, it thinks "3" is a
  perfectly  valid  form  for  a float to be in (and by its spec, very
  well could be right).

  Just  one of those things that violate the very rule-of-thumb Theory
  of  Least Surprise ("Things shouldn't leave you scratching your head
  a  moment  saying,  'Huh.'").  Not  a  rarity  in  Erlang, but not a
  game-breaker,  either.  As  I  said  to  Joe  Armstrong off-list, it
  probably  wouldn't  hurt  for  the string module to have a to_number
  func  that  took a string of either flavour and returned a float/int
  appropriately when you just don't care about the difference.

  Not that its hard to write, but it can be a tiny annoyance.

-- 
 Alexander Williams  (thantos@REDACTED)
The Squid's Redoubt: http://chancel.org:8000/Redoubt
  Currently Playing: B-52s, The - There's a Moon in the Sky (Called the Moon)
              Album: The B-52's




More information about the erlang-questions mailing list