Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cast Operator

GC17Jun 11 2018 — edited Jun 11 2018

Hello everyone!

I have a question regarding cast operators and data loss, specifically converting from int to byte.

If I start out with 200 as an int variable, and convert it to a byte shouldn't I get -72, since the first binary digit of value "128" is used to determine the sign. For some reason, I am not getting -72, but -56 instead. Could someone help me resolve this discrepancy?

Thank you very much!

Comments

EdStevens

This really has nothing to do with SQL Developer (the subject of this forum). It is a much better fit in SQL & PL/SQL.
And just as a side comment, storing 'age' as data is a flawed design. The 'age' of everyone and every thing is increasing by the day, if not by the second. What is your plan to keep 'age' current? Better to store 'date of birth' and the calculate 'age' when needed at run-time.

User_H3J7U

The 'age' of everyone and every thing is increasing by the day, if not by the second.
Sometimes the age stops increasing.
изображение.png

EdStevens

Pour me one!
Of course, that's not actually the age, but the amount of time it was 'aged' in the barrel before bottling.

1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 9 2018
Added on Jun 11 2018
2 comments
292 views