0

Can we use the Long data type for a short Value?

Eg:long a=2; Is it correct??

14th Aug 2016, 6:28 PM
Ayush Keshri
Ayush Keshri - avatar
5 Respuestas
+ 1
Yes, because the size of long data type is bigger than short.
14th Aug 2016, 6:45 PM
WPimpong
WPimpong - avatar
0
The best practices is to use L or l with numbers when asdiging to long daya type. ex: long a = 2L; Here no casting.
14th Aug 2016, 7:30 PM
Tiger
Tiger - avatar
0
ok thanks..It means that long data types' values need casting...Correct
15th Aug 2016, 7:07 AM
Ayush Keshri
Ayush Keshri - avatar
0
As Mazen said, it need L or l with the number.
15th Aug 2016, 8:29 AM
WPimpong
WPimpong - avatar