Skip to Content
Solidity Programming Essentials
book

Solidity Programming Essentials

by Ritesh Modi
April 2018
Intermediate to advanced
222 pages
5h 28m
English
Packt Publishing
Content preview from Solidity Programming Essentials

Explicit conversion

Explicit conversion is required when a compiler does not perform implicit conversion either because of loss of data or a value containing data not falling within a target data type range. Solidity provides a function for each value type for explicit conversion. Examples of explicit conversion are uint16 conversion to uint8. Data loss is possible in such cases.

The following code listing shows examples for both implicit and explicit conversions:

  • ConvertionExplicitUINT8toUINT256: This function executed explicit conversion from uint8 to uint256. It is to be noted that this conversion was also possible implicitly.
  • ConvertionExplicitUINT256toUINT8: This function executed explicit conversion from uint256 to uint8. This conversion ...
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

Solidity Programming Essentials - Second Edition

Solidity Programming Essentials - Second Edition

Ritesh Modi
The Go Programming Language

The Go Programming Language

Alan A. A. Donovan, Brian W. Kernighan
Linux Kernel Programming

Linux Kernel Programming

Kaiwan N. Billimoria
Programming Rust, 2nd Edition

Programming Rust, 2nd Edition

Jim Blandy, Jason Orendorff, Leonora F. S. Tindall

Publisher Resources

ISBN: 9781788831383Supplemental Content