# Thread: Need help in getting the integer value

1. ## Need help in getting the integer value

Hello I wrote this small. It takes a number fron 1 - 1024 rescales it and gives out a number between 1 - 363. But P_Number is a float. Is it possible to calculate P_Number as a float but only accept the integer part of the result. (e.g. if P_Number = 127.946) is it possible only to accept 127 or 128 and ignore the 0.946 part and send the integer result only to calculate DC. I don't really care if DC is a floating point number but I need the P_number to be an interger. If so can someone please show me how. I appreciate any help from anyone.

Code:
```#include <stdio.h>

int main()

{

float P_Number, DC, A_Number;

printf("please enter the conversion number: ");
scanf("%f",&A_Number);

P_Number = (A_Number/1024)*363;

printf("The P_number is %f \n", P_Number);

DC = P_Number / 3.63;

printf("The DC is %f \n", DC);

return 0;
}```

2. I believe if you declared P_Number as an int and did
Code:
`P_Number = (A_Number*363)/1024;`
you would get what you want (since 1024*363 shouldn't overflow anything -- edit unless you have 2-byte ints). Integer division will always round down, which seems like what you want.