Help rounding-off numbers (not using printf)

Robert Ransbottom rob at phavl.UUCP
Sun May 21 14:22:00 AEST 1989


In article <2730 at oregon.uoregon.edu>, michelbi at 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

Seems unlikely, consider the vagaries of this with binary representation
and decimal conceptualization.

Printf() was a good suggestion.  Look at sprintf to print to a string,
and strtod to convert it back.  

WARNING:  This should do the trick, but again the result is not 
as straight-forward as you _might_ think.

Hope this helps.

rob

kill( blair, SIGKILL)
-- 
 ...!uunet!phavl!rob              Robert Ransbottom



More information about the Comp.lang.c mailing list