pragma solidity ^0.4.0; /* Author: Robert Lie (mobilefish.com) More information: https://www.mobilefish.com/developer/blockchain/blockchain_quickguide_ethereum_tools.html Purpose: Investigate the different solidity data types: - How to use - What are the max and min values The information is based on: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI Note: The fixed types were not implemented in v0.4.14 Need to update this test contract when fixed types are implemented. Tools to convert bignumbers (dec to hex and reverse): http://www.wolframalpha.com/input/?i=2%5E128 https://www.mobilefish.com/services/big_number/big_number.php */ contract Types { //---------------------------------------------- // uint //---------------------------------------------- // uint256 range: 0 to 2^256 // 2^256 = 115792089237316195423570985008687907853269984665640564039457584007913129639936 // Max value: 2^256 - 1 uint256 a1 = 115792089237316195423570985008687907853269984665640564039457584007913129639935; // Can assign hex value; uint256 aa1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; uint8 a2 = 2; // uint synonym for uint256 uint b1 = 115792089237316195423570985008687907853269984665640564039457584007913129639935; //---------------------------------------------- // int //---------------------------------------------- // int256 range: -2^(n-1) to +2^(n-1) // 2^255 = 57896044618658097711785492504343953926634992332820282019728792003956564819968 // Max pos value: +2^(n-1) - 1 int256 a3 = 57896044618658097711785492504343953926634992332820282019728792003956564819967; // Max neg value: -2^(n-1) int256 a4 = -57896044618658097711785492504343953926634992332820282019728792003956564819968; // int synonym for int256 int b3 = 57896044618658097711785492504343953926634992332820282019728792003956564819967; int b4 = -57896044618658097711785492504343953926634992332820282019728792003956564819968; //---------------------------------------------- // address //---------------------------------------------- // address: equivalent to uint160 // uint160 range: 0 - 2^160 // 2^160: 1461501637330902918203684832716283019655932542976 // Max value: 2^160 - 1 address a5 = 1461501637330902918203684832716283019655932542975; // In hex: But this is not a valid address address a6 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; //---------------------------------------------- // bool //---------------------------------------------- // bool: equivalent to uint8 restricted to the values 0 and 1 bool a7 = true; // Not allowed // bool a8 = 1; bool a9 = false; // Not allowed // bool a10 = 0; //---------------------------------------------- // bytes //---------------------------------------------- // bytes: binary type of M bytes, 0 < M <= 32. // Max value (dec), will give an warning: // decimal literal assigned to bytes bytes32 a10 = 115792089237316195423570985008687907853269984665640564039457584007913129639935; bytes32 a11 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // byte synonym for bytes1 byte a12 = 0xFF; //---------------------------------------------- // fixed //---------------------------------------------- // I was investigating the fixed data types in solc v0.4.14. // But fixed data types were not implemented yet. // I will continue with this when it is implemented. // // UnimplementedFeatureError: Not yet implemented - FixedPointType. // fixedx: signed fixed-point decimal number of M bits, // 0 < M <= 256, M % 8 ==0, and 0 < N <= 80, // which denotes the value v as v / (10 ** N). // Max value 2^8 - 1 = 255 // 10^1 = 10 // Max value ufixed8x1 = 255 / 10 = 25.5 // ufixed8x1 a10 = 25.5; // Largest value ufixed256x1 // ufixed256x1 a11 = 11579208923731619542357098500868790785326998466564056403945758400791312963993.5; // Smallest value ufixed8x80 // ufixed8x1 a12 = 0; //---------------------------------------------- // string //---------------------------------------------- // UTF stands for Unicode Transformation Format. // The '8' means it uses 8-bit blocks to represent a character. // The number of blocks needed to represent a character varies from 1 to 4. }