home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d2xx
/
d222
/
plplot.lha
/
Plplot
/
src
/
source.zoo
/
plform.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-05-15
|
1KB
|
38 lines
/* 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>
#include <string.h>
void plform(value,mode,prec,result)
float value;
int mode, prec;
char *result;
{
int j, expon;
char form[10];
char temp[30];
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;
if (j == 0) fatal("Unrecognized scientific notation");
sscanf(&temp[j],"%d",&expon);
sprintf(form,"%-d",expon);
strcpy(&temp[j-1],"x10\\u");
strcat(temp,form);
strcpy(result,temp);
}
}