Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 6, 2019 06:01
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/69e4adbe7b0efea31cad9599e3fa25af to your computer and use it in GitHub Desktop.
Save parzibyte/69e4adbe7b0efea31cad9599e3fa25af to your computer and use it in GitHub Desktop.
Redondear con floor, ceil y round en C - https://parzibyte.me/blog/2018/11/08/redondear-numeros-en-c/
/*
Redondear números con los 3 métodos en C
@author parzibyte
parzibyte.me/blog
*/
#include<stdio.h>
#include<math.h>
int main(){
float numero = 28.11;
float redondeado = round(numero);
float redondeadoHaciaAbajo = floor(numero);
float redondeadoHaciaArriba = ceil(numero);
printf("%0.2f con round es %0.2f, con floor %0.2f y con ceil %0.2f", numero, redondeado, redondeadoHaciaAbajo, redondeadoHaciaArriba);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment