Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

aswathymohan

Member level 4
Joined
Nov 11, 2012
Messages
68
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,288
Activity points
1,727
Hi

How to display 230.5678956 as 230.56 in mikroc

Regards
 

I am using pic16f877a,sprintf is not supported in this uc.
 

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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top