How do I check the type of a value on runtime?
I’d like to find out where I’m creating doubles.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re using Objective-C classes, then the
[myObject isKindOfClass: [InterestingClass class]]test is available. If you’re using primitive types (which your question, quoting the ‘double’ type, suggests), then you can’t. However unless you’re doing some very funky stuff, the compiler can tell you when primitive types do or don’t match up, and when it doesn’t will perform implicit promotion to the desired type.It would be beneficial to know a little more about what the specific problem is that you’re trying to solve, because it may be that the solution doesn’t involve detecting the creation of doubles at all :-).