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 197 views
2 answers 240 views
1 answer 248 views
1 answer 297 views
1 answer 194 views
1 answer 166 views
...