Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created March 1, 2019 23:30
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/eded5d9bb9b7890e6b246fa4c2fd1146 to your computer and use it in GitHub Desktop.
Save parzibyte/eded5d9bb9b7890e6b246fa4c2fd1146 to your computer and use it in GitHub Desktop.
class Main {
public static void main(String[] args) {
double numero = 3.1416;
System.out.printf("El número originalmente es: %f\n", numero);
double parteDecimal = numero % 1; // Lo que sobra de dividir al número entre 1
double parteEntera = numero - parteDecimal; // Le quitamos la parte decimal usando una resta
System.out.printf("Parte entera: %f. Parte decimal: %f\n", parteEntera, parteDecimal);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment