A general programming discussion community.
Rules:
- Be civil.
- Please start discussions that spark conversation
Other communities
Systems
Functional Programming
Also related
- 0 users online
- 5 users / day
- 14 users / week
- 44 users / month
- 138 users / 6 months
- 1 subscriber
- 336 Posts
- 544 Comments
- Modlog
Because gnu.org says so: “The exponent in a hexadecimal floating constant is an optionally signed decimal integer that specifies a power of 2 (not 10 or 16) to multiply into the number.” https://www.gnu.org/software/c-intro-and-ref/manual/html_node/Floating-Constants.html
I just learned something, thanks!
From the documentation (emphasis mine):
You can find the full documentation here: cppreference.com
So in your example
0x1P1
means 116 * 2^(110) = 2deleted by creator
There is decimal scientific notation for specifying a decimal exponent already (
123e4 = 123×10^4
).And I don’t know why the committee preferred base 2 over base 16, I think it really depends on the use case which one is more useful.
Presumably related to binary, at least indirectly.
I’ve never seen P used as an operator and find nothing with a quick Google search. What’s it do?
Edit: What’s it supposed to do/where did it come from?
It’s a C++17 feature that allows specifying a power of two (as decimal exponent) by which the fractional part should be multiplied.
So mPn is m*1<<n? (For integer values of n)
Yeah, you could express it like that
1P1 = 1 * 2^1 = 2
deleted by creator
Hex digits are 0-9 and A-F. I don’t think P is a digit.
deleted by creator