0

hallo
i need 2 deal with each digit after the floating point.
ex . 12.5678
i need 2 compare the 12.5 with another number and then the 12.56 and then 12.567 and so on till 4 digits

is there is a function that takes the int number and one number after the floating point from the whole float number

2
Contributors
1
Reply
2
Views
11 Years
Discussion Span
Last Post by jetru
0

You can get the parts by doing this

float a=12.5678;
int whole_part=a;
float dec_part=a-whole_part;

If you want only one decimal part try this

float dec_part_1=((int)(dec_part*10))/10;

If you want two, replace the 10 with 100 and so on.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.