How to display a float value having only 2 digits after the decimal point in Mikroc

Status
Not open for further replies.
There is no printf() in mikroC. To use FloatToStr() you have to define a char array which has minimum 23 elements like flt2strBuff[23].

"230.5678956"


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
unsigned char i = 0;
 
while(flt2strBuff[i]) {
 
    while(flt2strBuff[i] != '.')i++;
    i += 3;
 
    flt2strBuff[i] = '\0';
 
}

 

Do you mean Mikroe MikroC?
I only use Mikropacsal, but maybe it works in C too
I Pascal you use a String. A String work like a Array
So YOu can terminate it with 0 at the point you want.
If you have a:=1.2345 and want 1.23 then write vor the Variable a
a[5]:=0;
LCDOut(a);

Then you get 1.23
I hope this works for you.
Why you don'T ask this in the Mikroe Community?
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…