stygops
Newbie level 6
hello,
im trying to send a float number from 89s8252 to pc via serial, using the term232 I can see the number that i was sended in th ecomputer, but this is not complete..
ex:
i send 98624.8736 and i receive 95624.8800...
why this occur??
my code is in C.
void main (void)
{
float conta = 0;
unsigned char cont;
bit buffer[40];
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 0xfd; /* TH1: reload value for 9600 baud */
TR1 = 1; /* TR1: timer 1 run */
TI = 1; /* TI: set TI to send first char of UART */
conta = 98624.8736;
sprintf(buffer, "%.4f\0", conta);
{
while(buffer[cont]!=0x00)
{
putchar(buffer[cont]);
cont++;
}
while(1){}
}
}
very thanks, sorry bad english ;p
im trying to send a float number from 89s8252 to pc via serial, using the term232 I can see the number that i was sended in th ecomputer, but this is not complete..
ex:
i send 98624.8736 and i receive 95624.8800...
why this occur??
my code is in C.
void main (void)
{
float conta = 0;
unsigned char cont;
bit buffer[40];
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 0xfd; /* TH1: reload value for 9600 baud */
TR1 = 1; /* TR1: timer 1 run */
TI = 1; /* TI: set TI to send first char of UART */
conta = 98624.8736;
sprintf(buffer, "%.4f\0", conta);
{
while(buffer[cont]!=0x00)
{
putchar(buffer[cont]);
cont++;
}
while(1){}
}
}
very thanks, sorry bad english ;p