How do you get one FLOAT variable to seperate into a main number and fraction.

i.e. If I had a FLOAT variable of 1.234, how do I get 1.234 into 2 new variables of 1.000 and 0.234.

I hope you understand the question!.

Rob.

Printable View

- 10-21-2001Robert_InglebySeperating Main And Fractional Numbers
How do you get one FLOAT variable to seperate into a main number and fraction.

i.e. If I had a FLOAT variable of 1.234, how do I get 1.234 into 2 new variables of 1.000 and 0.234.

I hope you understand the question!.

Rob. - 10-21-2001Salem
It's called modf(), and it's found in math.h

Reading the manual page for it is up to you. - 10-22-2001John
assign the float to an integer for the integer value.

subtract that integer value from the original float to get the fractional part.