Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

pic16f877 based rpm meter

Status
Not open for further replies.

acemicroservices

New Member
Hi ,everyone
this is my first post ,

i am doing pic16f877 based rpm meter project in htc
all this is running properly but cant give correct answer because

answer comes in float means 1234.123123 or as per captured value

now how can i convert this float to int
 
How many decimal places???? ie.. 1234.567 can be multiplied by 100 to give 1234567 then you can insert the decimal place... Its so easy to write a decimal to ascii routine that places a decimal point.
 
thank u all of u
no question when decimal comes 2 or 3 or 4 digit but what if "1234.123456789123455678898" simply its in double or 32 bit decimal,
what i actually need is if number is 1234.1234 then ans=1234 i don't need numbers after decimal /fractional
waiting for valuable help
 
thank u all of u
no question when decimal comes 2 or 3 or 4 digit but what if "1234.123456789123455678898" simply its in double or 32 bit decimal,
what i actually need is if number is 1234.1234 then ans=1234 i don't need numbers after decimal /fractional
waiting for valuable help

hi,
I dont use 'C,' but surely there must be a 'C' operation/command that can extract the integer part of the number.??

E

**broken link removed**
 
If you have sprintf function, you can do something like this:

char buffer[20];
float value = 1234.5678;

sprintf(buffer, "%.0f", value);

// after that the string "1234" is in the buffer. You can change the number of digits after decimal point; Two digits after decimal point: sprintf(buffer, "%.2f", value);
 
Last edited:
If the OP declares an integer variable and equates the FP value to it, the compiler should drop the decimal.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top