Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: method of getting around the rounding of floating and double precision numbers using printf(). Keywords: rounding Message-ID: <10529@smoke.BRL.MIL> Date: 15 Jul 89 04:46:08 GMT References: <4864@ihlpe.ATT.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 10 In article <4864@ihlpe.ATT.COM> jec@ihlpe.ATT.COM (Morris) writes: >I have tried all the usual stuff with the printf() statement [the >%*.*f,7,2,variable_name or %4.2f or %.2 etc.,etc.] but none of >these techniques were able to get around the rounding when printing >these variables. printf() is required to always print a properly-rounded representation of its floating-point argument. If you want to print some sort of truncated quantity, you'll have to truncate it yourself before feeding it to printf(). For example: x = floor(x*100.0) / 100.0;