Keil Logo

modf

Summary
#include <math.h>

double modf (
  double val,    /* value to calculate modulo for */
  double *ip);   /* integer portion of modulo */
Description

The modf function splits the floating-point number val into integer and fractional components. The fractional part of val is returned as a signed floating-point number. The integer part is stored as a floating-point number at ip.

Return Value

The modf function returns the signed fractional part of val.

Example
#include <math.h>
#include <stdio.h> /* for printf */

void tst_modf (void) {
  float x;
  float int_part, frc_part;

  x = 123.456;

  frc_part = modf (x, &int_part);

  printf ("%f = %f + %f\n", x, int_part,frc_part);
}
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.