Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Objective-C, fabsf() has the wrong result type

Tags:

objective-c

If in the Xcode's debug console I type

(lldb) p (float)fabsf(-5.0f)
(float) $22 = 0
(lldb) p (double)fabsf(-5.0f)
(double) $23 = 5

where the first result casting to float (without casting, the p command can't recognize the fabsf return type) is wrong no matter the parameter.

But in the library headers the return type of fabs is clearly a float. Can somebody explain me this?

ios9.2: math.h

...
extern float fabsf(float);
extern double fabs(double);
extern long double fabsl(long double);
...

Is there some lldb mechanism or issue which I am not aware of, or really a language implementation issue (guess not...)?

like image 305
jalone Avatar asked Feb 01 '16 17:02

jalone


1 Answers

It was pretty sure a bug of lldb console in Xcode 7, and a ticket was created for it.

The issue is not present any more in Xcode 8.0.

like image 197
jalone Avatar answered Jan 03 '23 15:01

jalone