03.类型和值
unit是无符号正整数
负数用int
// SPDX-License-Identifier: MIT
pragma solidity 0.8.18;
contract ValueType {
bool public b = true;
/*
uint stands for unsigned integer, meaning non negative integers
different sizes are available
uint8 ranges from 0 to 2 ** 8 - 1
uint16 ranges from 0 to 2 ** 16 - 1
...
uint256 ranges from 0 to 2 ** 256 - 1
*/
uint256 public u = 123;
/*
Negative numbers are allowed for int types.
Like uint, different ranges are available from int8 to int256
int256 ranges from -2 ** 255 to 2 ** 255 - 1
int128 ranges from -2 ** 127 to 2 ** 127 - 1
*/
int256 public i = -123;
// minimum and maximum of int
int256 public minInt = type(int256).min;
int256 public maxInt = type(int256).max;
// address是16位的地址
address public addr = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;
}