How to get absolute value for float
#include <math.h> #include <stdio.h> int main(void) { printf("%1.1f %1.1f", fabs(1.0), fabs(-1.0)); return 0; }