Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!mahendo!nereid!robert From: robert@nereid.jpl.nasa.gov (Robert Angelino) Newsgroups: comp.lang.c Subject: Padding floats with zeros in printf?? Message-ID: <6158@mahendo.Jpl.Nasa.Gov> Date: 5 Apr 91 21:41:20 GMT Sender: news@mahendo.Jpl.Nasa.Gov Reply-To: robert@triton.JPL.NASA.GOV Organization: Technology Development Group (JPL) Lines: 39 background: I'm running SunOS 4.1 on a SPARC using the Sun C compiler. I'm doing something like so: printf("%02.3f\n",1.1324); and I'm getting this: 1.132 I want something like 01.132 The book "C A Reference Manual" by Steele & Harbison say that the following should work: printf("%02.3f\n",1.1324); OR printf("%#02.3f\n",1.1324); OR printf("%02.3g\n",1.1324); OR printf("%#02.3g\n",1.1324); Now, I've tried all of these (including the "hammer") and nothing seems to work. If the book says it should work then the compiler is not doing it's job correctly. Does anyone know how to get around this using this compiler??? Please e-mail directly. thanks in advance -- - ------ - Robert Angelino | | | ---- \ | | ms T-1704L | | | | \ | | | 4800 Oak Grove Drive | | | | -- | | | Pasadena, CA 91109 ---| | | | \__/ | |___ robert@triton.jpl.nasa.gov \____|et |_|ropulsion |_____\aboratory (818) 354-9574