Take the 2-minute tour ×

Could you please explain double hex number representation that uses 'p' character :

0x1.5p10 or 0x1P-1

Thank you in advance.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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:

0x1.5p10 = (1 + 5/16) x 2^10 = 1344.0
0x1p-1 = 1 x 2^-1 = 0.5

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.fffffffffffffp1023 in hexadecimal floating-point. Writing it exactly in decimal gives us:


which is rather cumbersome.

share|improve this answer
Thank you, Stephen :) –  StKiller Sep 15 '12 at 16:30

Your Answer


