[Xastir] A minor miracle.....

Curt, WE7U archer at eskimo.com
Mon May 23 13:11:46 EDT 2005


On Sat, 21 May 2005, Henk de Groot wrote:

> Richard E. Polivka schreef:
> > Now for the C wiz's: I used 0%8.4f to supply the leading zero. I doubt
> > this is correct. What would be correct to make 88.0102 print out as
> > 088.0102?
>
> Well, this is not correct, unless you want 100.0102 to appear like
> 0100.0102 :-).
>
> I would assume %08.4f would do the trick, the 0 indicates to prefix the
> number with zeros unitl the length is 8 positions. I'm not sure however if
> this is portable, i.e. if all *printf/*scanf implementations support it.

I don't know if you can ever say that ALL *printf/*scanf functions
support any particular feature.  There's a lot of code in those
functions, and it seems every OS does things just a bit different.

That said, "%08.4f" should have worked on nearly any modern
implementation.  It's a fairly standard option.


  > cat test3.c

  #include <stdio.h>

  int main(void) {
      printf("%08.4f\n", 1.2);
  }


  > gcc test3.c
  > ./a.out
  001.2000


--
Curt, WE7U.   APRS Client Comparisons: http://www.eskimo.com/~archer
"Lotto:    A tax on people who are bad at math." -- unknown
"Windows:  Microsoft's tax on computer illiterates." -- WE7U
"The world DOES revolve around me:  I picked the coordinate system!"



More information about the Xastir mailing list