-
-
Save phaya/9ed685dea00d3c2f2981 to your computer and use it in GitHub Desktop.
Me ponga como me ponga 1 partido por 2 es 0 en vez de 0.5 ¿cómo puede ser? ¿cómo lo modificarías para obtener el resultado correcto?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
printf("%d\n", 1/2); | |
printf("%.2f\n", 1/2); | |
return 0; | |
} |
Esta última observación (un solo float) no la sabía. Tomo nota.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
¡Perfecto! De hecho, con que uno de los dos números sea
float
vale, por ejemplo, 1.0/2