fork(1) download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main(void) {
  5. float f = 1.10;
  6. float truncado = (f - trunc(f)) * 10;
  7. printf("Truncado: %f\n", truncado);
  8. float mod = fmodf(truncado, 1.0f);
  9. printf("Mod: %f\n", mod);
  10. if (mod != 0){
  11. printf("%.2f", f);
  12. }
  13. else{
  14. printf("%.1f", f);
  15. }
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
Truncado: 1.000000
Mod: 0.000000
1.10