|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Short + short = not short?
Code:
short ONE = (short)1; short a = (short)1; a = a+ONE; Why does this give me possible loss of precision error? Im not widening nor shortening, just adding two shorts. |
|
#2
|
|||
|
|||
|
Yeah, basically, on your case(don't ask me why, mabybe someone else knows), short+short = int.
What you want to do is cast the operation: Code:
short a = 1; short A = 1; a = (short)(a+A); |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > Short + short = not short? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|