Could you please explain double hex number representation that uses ‘p’ character :
0x1.5p10 or 0x1P-1
Thank you in advance.
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.
This actually isn’t specific to Objective-C; it’s a standard feature inherited from C. It provides a way to write floating-point numbers without rounding. It is clearly documented in the C standard, but here’s a quick overview:
Hexadecimal floating-point literals have the form
0x[significand]p[exponent], where[significand]is a hexadecimal number, and[exponent]is a base-10 integer. The number has the value[significand] x 2^[exponent].So, for example:
These examples aren’t particularly interesting, because they can both easily be written exactly as decimal floating-point literals as well. The notation gets more interesting as the exponent gets more extreme. For example, consider the largest finite double-precision number:
0x1.fffffffffffffp1023in hexadecimal floating-point. Writing it exactly in decimal gives us:which is rather cumbersome.