ARPDAS_QNX6 1.0
dtoe.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include "dtoe.h"
00004 
00005 char rcsid_dtoe_c[] =
00006         "$Header: /cvsroot/arp-das/nortlib2/src/dtoe.c,v 1.3 2012/02/27 20:03:06 ntallen Exp $";
00007   
00008 char *dtoe( double v, int width, char *obuf ) {
00009   static char sbuf[30];
00010   char *buf;
00011   int dec, sign, i, j;
00012 
00013   if ( obuf == 0 ) {
00014     obuf = sbuf;
00015     if ( width > 29 ) width = 29;
00016   }
00017   if ( width < 7 ) snprintf( obuf, width+1, "*******" );
00018   else {
00019     int nn;
00020     int prec = width-7;
00021     nn = snprintf( obuf, width+1, "% #*.*e", width, prec, v );
00022     if ( nn == width+1 ) {
00023       if ( prec > 0 ) {
00024         nn = snprintf( obuf, width+1, "% #*.*e", width-1, prec-1, v );
00025       } else {
00026         nn = snprintf( obuf, width+1, "% *.*e", width-1, prec, v );
00027       }
00028     }
00029     if ( nn != width ) obuf[0] = '!';
00030   }
00031   return obuf;
00032 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines