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.

Looking for C code for converting float to int value

Status
Not open for further replies.

london

Member level 4
Member level 4
Joined
Jun 30, 2006
Messages
79
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,945
C code

Dear All,
This is my requirment,
float mV=0.0;
mV=(Count+23.484)/27.222;
result of mV will be xxxx.xxxxx
but finally i need the mV value in a integer means, xxxx only.
How can i get this. what is the another C code function i have to write to convert float to int value. if any body know help me!
 

Re: C code

I think you can use a type casting.

like this

mV=(int)mV;

Try this and tell me if it works.

ATLAJ
 

    london

    Points: 2
    Helpful Answer Positive Rating
Re: C code

Hi!
include the file "math.h" in your project and use the function

double x;
x = floor(mV);

x will hold the largest whole number not greater than mV

e.g if mV = 456.789;
then x will be 456.

If this does not solve your problem then feel free to ask.

Best of luck.

Regards.
 

    london

    Points: 2
    Helpful Answer Positive Rating
Re: C code

london said:
Dear All,
This is my requirment,
float mV=0.0;
mV=(Count+23.484)/27.222;
result of mV will be xxxx.xxxxx
but finally i need the mV value in a integer means, xxxx only.

By the way you know it's faster with the controller to calc
(500*Count + 11742)/13611 ?

by Gomez
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top