[HD Pg 0, Sec. 5.1.5 - numeric-promotion-and-casting]
Moderator: admin
-
- Posts: 202
- Joined: Mon Apr 02, 2018 8:40 am
- Contact:
[HD Pg 0, Sec. 5.1.5 - numeric-promotion-and-casting]
Does numeric promotion applies to wrappers as well?
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 0, Sec. 5.1.5 - numeric-promotion-and-casting]
Good question. Yes, it does. So, the following will not compile -
Byte b1 = 10;
Byte b2 = -b1;
The book should have mentioned this. Will get it updated.
thank you for your feedback,
Paul.
Byte b1 = 10;
Byte b2 = -b1;
The book should have mentioned this. Will get it updated.
thank you for your feedback,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 202
- Joined: Mon Apr 02, 2018 8:40 am
- Contact:
Re: [HD Pg 0, Sec. 5.1.5 - numeric-promotion-and-casting]
When will be the book updated? I am using Kindle version, will I receive the update?
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 0, Sec. 5.1.5 - numeric-promotion-and-casting]
We update the version after a few errors are reported. There is no fixed schedule.
Regarding Kindle, I think Amazon delivers the updated version automatically to existing customers but I am not sure about when they do it.
HTH,
Paul.
Regarding Kindle, I think Amazon delivers the updated version automatically to existing customers but I am not sure about when they do it.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 202
- Joined: Mon Apr 02, 2018 8:40 am
- Contact:
Re: [HD Pg 0, Sec. 5.1.5 - numeric-promotion-and-casting]
It is not mentioned what happens in case one operand is double and the other is long ??2. Binary numeric promotion - Both the operands of a binary operator are promoted to an int but if any of the operands is larger than an int, the other operand is promoted to the same type as the type of the larger one. Thus, for example, if both the operands are of type byte,
then both are promoted to int but if any of the operands is a long, float, or double, the other one is also promoted to long, float, or double, respectively.
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 0, Sec. 5.1.5 - numeric-promotion-and-casting]
It says, "if any of the operands is larger than an int, the other operand is promoted to the same type as the type of the larger one" and then, "For example, if any of the operands is a long, float, or double, the other one is also promoted to long, float, or double, respectively".
So, between long and double, double is larger, so long will be promoted to double.
Should be improved for clarity.
So, between long and double, double is larger, so long will be promoted to double.
Should be improved for clarity.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: Bing [Bot] and 42 guests