There is a standard C function called modf(). You give modf() a double, and it calculates the integer part and the fraction part of the number. For example, if you give it 3.14, 3 is the integer part and 0.14 is the fractional part.
You, as the caller of modf(), want both parts. However, a C function can only return one value. How can modf() give you both pieces of information?
When you call modf(), you will supply an address where it can stash one of the numbers. In particular, it will return the fractional part and copy the integer part to the address you supply. Create a new project: a C Command Line Tool named PBR.
#include <stdio.h> #include <math.h> ...