jalone jalone - 1 year ago 103
Objective-C Question

objective c fabsf() wrong result type

If in the xcode 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
command can't recognize the fabsf return type) is wrong no matter of 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 whose i am not aware of, or really a language implementation issue (guess not...)?

Answer Source

It was pretty sure a bug of lldb console in xcode7. A ticket was created for it. The issue is not present anymore in xcode8.0.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download