On Oct 18, 2016, at 1:56 AM, Patrick J. Collins <[email protected]> wrote: >>> CGFloat is a float, yet it returns 0??????????? WTF? >> >> It isn’t a float. What you’re seeing in the debugger *confirms* that CGFloat >> is 64 bits. > > Hmm.. I guess I don't understand that then. My logic was because > casting as a double returns the expected value, and casting as a CGFloat > does not, that it couldn't be a double...
To expand on Quincey's explanation, what's going on here is that the "cast" syntax in the debugger is doing something different from what a cast in sourcecode would do. In the compiled program, the compiler "knows" (possibly incorrectly, as in your case!) what type the method returns, and the cast is converting types--- e.g. converting from float to double, changing the bits but preserving the numerical value (which is what you want). In the debugger, something slightly different is happening. In many cases the debugger doesn't know what the return type of the method is. You use the cast syntax to tell the debugger what the return type is, and it interprets the bits coming out of the method call that way. In effect you're telling the debugger "Okay, pretend this method was declared to return double, then call it". > Sorry for my temper fit. Sometimes I go argghhh when things make no > sense, and I am afraid I am going to need to go out and buy an iPhone7 > now because I have no idea whether there's something else that's going > to behave differently on it compared to all these other devices. I think that running your app in the simulator for a 64-bit phone architecture would also reveal this bug. (The simulator targets compile to either i386 or x86_64 depending on whether the phone is a 32-bit or 64-bit ARM variant respectively.) Of course there's no substitute for testing on real hardware, but the simulator can flush out 32/64 bugs. I'm a little surprised that the compiler didn't warn or error when it had two conflicting declarations for that method, actually.
_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/objc-language/archive%40mail-archive.com This email sent to [email protected]
