else if((c[3] > 0x60) && (c[3] < 0x67))
Hd[3] = ((c[3] - 0x57) & 0x0f);
else
Hd[3] = ((c[3] - 0x30) & 0x0f);
if((c[2] > 0x40) && (c[2] < 0x47))
Hd[2] = ((c[2] - 0x37) & 0x0f);
else if((c[2] > 0x60) && (c[2] < 0x67))
Hd[2] = ((c[2] - 0x57) & 0x0f);
else
Hd[2] = ((c[2] - 0x30) & 0x0f);
Decimal = (float)(((float)(Hd[2] * 16) + (float)(Hd[3]) + DTc[1])/ 256.0);
if((c[1] > 0x40) && (c[1] < 0x47))
Jiema[1] = ((c[1] - 0x37) & 0x0f);
else if((c[1] > 0x60) && (c[1] < 0x67))
Jiema[1] = ((c[1] - 0x57) & 0x0f);
else
Jiema[1] = ((c[1] - 0x30) & 0x0f);
if((c[0] > 0x40) && (c[0] < 0x47))
Jiema[0] = ((c[0] - 0x37) & 0x0f);
else if((c[0] > 0x60) && (c[0] < 0x67))
}
Jiema[0] = ((c[0] - 0x57) & 0x0f);
else
Jiema[0] = ((c[0] - 0x30) & 0x0f);
ShuFU = ((Jiema[0] & 0x08) >> 3) > 0; JieFU = ((Jiema[0] & 0x04) >> 2) > 0;
Jiema[2] = (Jiema[0] & 0x03) * 16 + Jiema[1];
if(JieFU)
returnflo = (float)pow(2, (-1) * Jiema[2]) * Decimal;
else
returnflo = (float)pow(2, Jiema[2]) * Decimal;
if(ShuFU)
returnflo = (-1) * returnflo;
return returnflo;
2) 浮点数到ASCII码: /* in:char * c:
存储浮点数转换后的ASCII码字符。
Float d: 要转换的浮点数。 Return : 无。 */
void D4toC(char * c,float d) {
BYTE i = 0, Jiema = 0;
memset(inbyte1, 0x30, sizeof(inbyte1)); memset(afterbyte2, 0x30, sizeof(afterbyte2)); memset(afterbyte3, 0x30, sizeof(afterbyte3)); memset(afterbyte4, 0x30, sizeof(afterbyte4)); char inbyte1[30];
BOOL ShuFu = FALSE, JieFu = FALSE; int inbyte2 = 0, inbyte3 = 0, inbyte4 = 0; char afterbyte2[30], afterbyte3[30], afterbyte4[30]; float F_afterbyte2 = 0, F_afterbyte3 = 0, F_afterbyte4 = 0;
inbyte1[10] = 0x0; afterbyte2[10] = 0x0; afterbyte3[10] = 0x0; afterbyte4[10] = 0x0;
if(d == 0)
{ } if(d < 0) { }
ShuFu = TRUE; d = (-1) * d;
for(int j = 0; j < 8; j++)
c[j] = 0x30;
return;
while(d > 1) { }
d =(float)(d / 2.0); i ++;
while(d <= 0.5) { }
JieFu = TRUE; d = (float)(d * 2.0); i ++;
if(d == 1) { }
for(int j = 2; j < 8; j++)
c[j] = 0x46;
else {
inbyte2 = (int)(d * 256);
F_afterbyte2 = (d * 256) - (int)(d * 256); inbyte3 = (int)(F_afterbyte2 * 256);
F_afterbyte3 = (F_afterbyte2 * 256) - (int)(F_afterbyte2 * 256); inbyte4 = (int)(F_afterbyte3 * 256);
F_afterbyte4 = (F_afterbyte3 * 256) - (int)(F_afterbyte3 * 256);
itoa(inbyte2, afterbyte2, 16); itoa(inbyte3, afterbyte3, 16); itoa(inbyte4, afterbyte4, 16);
if(inbyte2 == 0) { }
else if(inbyte2 < 16)
c[2] = 0x30; c[3] = 0x30;