Skip to Content
Ethereum Cookbook
book

Ethereum Cookbook

by Manoj P R
August 2018
Intermediate to advanced
404 pages
11h 19m
English
Packt Publishing
Content preview from Ethereum Cookbook

There's more...

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Building Ethereum Dapps

Building Ethereum Dapps

Roberto Infante
Ethereum For Dummies

Ethereum For Dummies

Michael G. Solomon

Publisher Resources

ISBN: 9781789133998Supplemental Content