Page 1 of 1

[HD Pg 56, Sec. 3.1.0 - data-types-in-java]

Posted: Thu Oct 04, 2018 6:44 am
by Arold Aroldson
Hi! I have a question about Data Types. If char's range is 0 to 2^7-1 why is it 0 to 65,535? 2^7-1 is 127 isn't it?

Re: [HD Pg 56, Sec. 3.1.0 - data-types-in-java]

Posted: Thu Oct 04, 2018 8:13 am
by admin
That looks like a typo. char is 16 bits, which means 0 to 2^16-1 and not 2^7-1.

Re: [HD Pg 56, Sec. 3.1.0 - data-types-in-java]

Posted: Wed Jan 09, 2019 3:25 pm
by OCAJO1
"Notes:
1. byte, char, short, int, and, long are called integral data types because they store
integral values."

It would be nice if note 1 had a sentence added to it explaining that if all or which one of the integrals hold precise values.

Well while I'm at it, do all integral hold precise values? Or is long a trouble maker ;)

Re: [HD Pg 56, Sec. 3.1.0 - data-types-in-java]

Posted: Wed Jan 09, 2019 10:53 pm
by admin
Integral values are, by definition, precise values. But noted.
Also, do you think you might be thinking of atomicity and not precision? Long is precise but operations on long are not atomic (a topic not on OCAJP but on OCPJP).
thank you for your feedback!

Re: [HD Pg 56, Sec. 3.1.0 - data-types-in-java]

Posted: Thu Jan 10, 2019 1:00 pm
by OCAJO1
Oops good thing you said something - to keep straight precision, atomicity, volatile variables and synchronization's idiosyncrasies, I'm trying to create my own chart of what does what :roll: