Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!news.cs.indiana.edu!arizona.edu!arizona!armstron Newsgroups: comp.lang.c Subject: Simple atof() question Message-ID: <1214@caslon.cs.arizona.edu> From: armstron@cs.arizona.edu (Jim Armstrong) Date: 19 Mar 91 15:52:35 GMT Distribution: na Organization: U of Arizona CS Dept, Tucson Lines: 26 How can I get atof() to return a float instead of a double? When I run this simple program I get n = 37.549999 instead of n = 37.55. What am I doing wrong? #include main() { double atof(); char buf[10]; float n; strcpy(buf,"37.55"); n = (float) atof(buf); printf("n = %f\n",n); } -- Jim Armstrong "The nonpayment and subsequent abuse of armstron@cs.arizona.edu socially powerless athletes is simply a {uunet|noao}!arizona!armstron form of modern-day slavery" --Rick Telander