📄 dbl2asci.c
字号:
/************************************************************* * File: lib/dbl2asci.c * Purpose: Part of C runtime library * Author: Phil Bunce (pjb@carmel.com) * Revision History: * 970304 Start of revision history */#include <defines.h>#define strequ(x,y) ((strcmp(x,y)==0)?1:0)char *dbl_to_ascii(in, dst)double *in;char dst[];{#ifdef FLOATINGPTint i;char tmp1[64],tmp2[64];long exp;char sign;double d;/* dtoa clobbers 'in' so copy it first */d = *in;dtoa(&d, tmp1,&sign,&exp); *dst=0;if(sign == '-') strcat(dst,"-");/* mantissa */if (strequ(tmp1,"0")) sprintf(tmp2,"0.%s",tmp1);else { sprintf(tmp2,"%c.%s",tmp1[0],&tmp1[1]); exp--; }for (i=strlen(tmp2);i<25;i++) tmp2[i] = '0';tmp2[i] = 0;strcat(dst,tmp2);/* exponent */sprintf(tmp1, "%02d", exp);if(tmp1[0]=='-') strcat(dst, "e");else strcat(dst, "e+");strcat(dst, tmp1);#else*dst=0;#endif /* FLOATINGPT */return(dst);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -