**** a simple question ****

Siping Liu siping at cathedral.cerc.wvu.wvnet.edu
Sat Sep 15 07:20:00 AEST 1990


How can I print out ONLY the significant digits of
a float number? As you know, "%f" fills in zero's if
the number does not have enough non-zero digits after
the point.

I'd like to have:
  for 3.12, print out 3.12;
  for 3.0, print out 3.0;
  for 3.12349, print out 3.1235;  (4 digits at most after the point)

How can I do this?

Thanks for your help.

siping at cerc.wvu.wvnet.edu



More information about the Comp.lang.c mailing list