0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Solidity】(tips)uintとintの上限下限値確認

Posted at

intは符号付き整数、uintは符号なし整数ですが、その上限下限値確認方法を下記します。
型の上限値と下限値はtype(型).maxとtype(型).minで確認できます。
例えばint8とuint8の上限下限値を確認するには、下記のようになります。
int8の範囲は-128 〜 127 、uint8の範囲は0 〜 255なので、
maxUvalue:255、minUvalue:0、maxvalue:127、minvalue:-128

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

contract Sample {
 
    uint8 public maxUvalue = type(uint8).max;
    uint8 public minUvalue = type(uint8).min;
    int8 public maxvalue = type(int8).max;
    int8 public minvalue = type(int8).min;
     
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?