Literal Oddities

I’m busy writing about literal style (prefer literals when you can but add typing) and stumbled across a form of binary exponentiation that I hadn’t used before.

Do you know what these two Swift literals evaluate to?

0x15p1, 0xA.8p2

I’ll give you a hint. The numbers must start with hex values and may include elements past the decimal point. The p exponentiation means “multiply by 2 raised to this power”, so 0x15p1 means 15 hex multiplied by 2, and 0xA.8p2 means A.8 hex multiplied by 4.

Of course you can just type them into a playground but where’s the fun in that?

let dent = 0x15p1

If you still don’t know the answers, I’m pretty sure that a pair of ordinary lab mice might.