How to get the absolute value of a float in C

1 Answer

0 votes
#include <stdio.h>
#include <math.h>

int main()
{
    float f = -3.14f;
    
    printf("%f\n", fabsf(f));
    
    return 0;
}



/*
run:

3.140000

*/

 



answered Jan 23, 2023 by avibootz

Related questions

1 answer 104 views
2 answers 119 views
1 answer 133 views
1 answer 208 views
1 answer 105 views
1 answer 82 views
...