August 2018
Intermediate to advanced
404 pages
11h 19m
English
Solidity also supports conversions between elementary types. Both implicit and explicit conversions work with data types in solidity.
If different types of values are used with assignment or arithmetic operations, the compiler tries to implicitly convert one value to the type of the other. An implicit conversion is possible if it matches semantically and no information is lost during the conversion. For example, uint128 can be converted to uint256 and int16 to int32, but int is not convertible to uint because uint cannot store -1. Furthermore, any unsigned integers can be converted to bytes, but not vice versa:
int8 a = 1;uint b = a + 1200;
You can also perform explicit type conversion to supported variables. Only do it if ...