home *** CD-ROM | disk | FTP | other *** search
- /* Formats a floating point value in one of the following formats */
- /* (i) If mode == 0, use floating point format with "precision" */
- /* places after the decimal point. */
- /* (ii) If mode == 1, use scientific notation with one place before */
- /* the decimal point and "precision" places after. */
-
- #include "plplot.h"
- #include <stdio.h>
- #ifdef PLSTDC
- #include <string.h>
- #else
- extern char *strcpy();
- extern char *strcat();
- #endif
-
- static PLINT setpre, precis;
-
- /* Set the number of points written after the decimal point in labels */
-
- void plprec(setp,prec)
- PLINT setp, prec;
- {
- setpre = setp;
- precis = prec;
- }
-
- void plform(value,mode,prec,result)
- PLFLT value;
- PLINT mode, prec;
- char *result;
- {
- PLINT j, expon;
- char form[10];
- char temp[30];
-
- if(setpre)
- prec = precis;
-
- if (mode == 0) {
- sprintf(form,"%%-.%df",prec);
- sprintf(temp,form,value);
- strcpy(result,temp);
- }
- else {
- sprintf(form,"%%-.%dE",prec);
- sprintf(temp,form,value);
- j = strpos(temp,'E') + 1;
- sscanf(&temp[j],"%d",&expon);
- sprintf(form,"%-d",expon);
- strcpy(&temp[j-1],"x10#u");
- strcat(temp,form);
- strcpy(result,temp);
- }
- }
-
-