
Implement a function that returns the absolute value of an int as a long, widening the value before it ever negates it.
abs_safe(42)Expected result
42For your own tracking. Tests grade your code.
abs_safe(-1024)Expected result
1024abs_safe(0)Expected result
0abs_safe(INT_MAX)Expected result
2147483647abs_safe(INT_MIN)Expected result
2147483648Expected files
abs_safe.cAllowed functions
None. Write every helper yourself.
Allowed headers

v0.40: Create exercises. Challenge the community.
Meet Studio →Implement a function that returns the absolute value of an int as a long, widening the value before it ever negates it.
abs_safe(42)Expected result
42For your own tracking. Tests grade your code.
abs_safe(-1024)Expected result
1024abs_safe(0)Expected result
0abs_safe(INT_MAX)Expected result
2147483647abs_safe(INT_MIN)Expected result
2147483648Expected files
abs_safe.cAllowed functions
None. Write every helper yourself.
Allowed headers

Run the tests to grade your code
Build your code, then check each test here. Open a result to inspect its output.