Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 28, 2019 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/b70a34650b40d9c36ef3f4dff617970e to your computer and use it in GitHub Desktop.
Save parzibyte/b70a34650b40d9c36ef3f4dff617970e to your computer and use it in GitHub Desktop.
#include <stdio.h> // printf
#include <math.h> // modf
int main(void) {
double numero = 123.45;
printf("El número es %f\n", numero);
// En las siguientes almacenamos las partes separadas
double parteDecimal, parteEntera;
parteDecimal = modf(numero, &parteEntera); // mandar apuntador de parteEntera
// modf devuelve la parte decimal, y pone la parte entera en la variable cuya dirección mandamos
printf("Parte entera: %f. Parte decimal: %f\n", parteEntera, parteDecimal);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment