Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!shadooby!accuvax.nwu.edu!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Help needed to round-off a number Message-ID: <17637@mimsy.UUCP> Date: 20 May 89 05:46:56 GMT References: <2666@oregon.uoregon.edu> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 13 In article <2666@oregon.uoregon.edu> michelbi@oregon.uoregon.edu (Michel Biedermann) writes: >Is there a C function (user defined or primitive (?)) that will let me >truncate or round-off a number UP TO a certain decimal place. For example >transforming .567 into .6 or -1.502 into -1.5. In the proposed ANSI C standard, printf is defined as rounding when given a floating point format with a particular precision. Both of these results will be obtained with a `%.1f' printf format (assuming a Unix or pANS-conformant printf). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris