How to convert primitive data types upward?
This a list of order primitives from biggest to smallest
- double x64 bits
- float
- long
- int
- short
- byte
So how do you convert primitive data types upward you must first understand the data types and how they are related to each other in this example you see the data types from biggest to smallest ^ . Now lets break this down to an example. In the following code i declare a value of “intValue” set to 100 and then passing that value to a new variable data typed as a double and giving it a name of “doubleStats” and setting it to intValue so the results is 100 (integer) gets (double) to 120.0 with the decimal of .0 making more precise although the integer value is truncated they fundamentally still have the same value, this type of converting is called implicit and reliable upward numeric conversion.
int intValue = 120;
double doubleStat = intValue;
I always had a passion for the field of STEM (Science, Technology, Engineering, and Math) and I knew I wanted to do something to make a difference in the world. I just didn’t know where to start. I was an immigrant in a new country, grew up in a tough environment, and wasn’t sure how… Read More