Page 1 of 1

problem

Posted: 27 Aug 2015 08:36
by gsim
hi every one : :cry: :roll: :
for more than three days i failed to solve this problem my problem is how to make this divition 1 or 2 /255 and show the result in usart all the times the result was wrong please help my. thanx in advance.
this my cod .

float per;
char per_txt[15] ;

void main(){
UART1_Init(9600);
per=(float)1/(float) 255;
floattostr(per,per_txt);
//UART1_Write_text(per_txt); //the result was w.215682e-4 allways is wrong sometimes h or g with number
sprintf(per_txt, "%12f",per); //also i used this and the result was -0.963375
UART1_Write_text(per_txt) ;

}

Re: problem

Posted: 27 Aug 2015 11:26
by Aleksandar.Mitrovic
Hi Gsim,

First, welcome on mikroE forum and to our community! :)


Can you please tell me in which compiler did you try to write this code?
And for which microcontroller?

I tested this code in mikroC PRO for PIC and I had the correct values in debug and on UART terminal as well.

Best regards,
Aleksandar