Solidity-types
提供:Dev Guides
堅牢性-タイプ
任意の言語でプログラムを作成する際、さまざまな変数を使用してさまざまな情報を保存する必要があります。 変数は、値を保存するために予約されたメモリの場所に他なりません。 これは、変数を作成するときに、メモリ内にスペースを確保することを意味します。
文字、ワイド文字、整数、浮動小数点、二重浮動小数点、ブールなどのさまざまなデータ型の情報を保存することができます。 変数のデータ型に基づいて、オペレーティングシステムはメモリを割り当て、予約メモリに保存できるものを決定します。
値タイプ
Solidityは、豊富な品揃えの組み込みおよびユーザー定義のデータ型をプログラマに提供します。 次の表は、7つの基本的なC ++データ型を示しています-
Type | Keyword | Values |
---|---|---|
Boolean | bool | true/false |
Integer | int/uint | Signed and unsigned integers of varying sizes. |
Integer | int8 to int256 | Signed int from 8 bits to 256 bits. int256 is same as int. |
Integer | uint8 to uint256 | Unsigned int from 8 bits to 256 bits. uint256 is same as uint. |
Fixed Point Numbers | fixed/unfixed | Signed and unsigned fixed point numbers of varying sizes. |
Fixed Point Numbers | fixed/unfixed | Signed and unsigned fixed point numbers of varying sizes. |
Fixed Point Numbers | fixedMxN | Signed fixed point number where M represents number of bits taken by type and N represents the decimal points. M should be divisible by 8 and goes from 8 to 256. N can be from 0 to 80. fixed is same as fixed128x18. |
Fixed Point Numbers | ufixedMxN | Unsigned fixed point number where M represents number of bits taken by type and N represents the decimal points. M should be divisible by 8 and goes from 8 to 256. N can be from 0 to 80. ufixed is same as ufixed128x18. |
住所
addressは、Ethereumアドレスのサイズを表す20バイトの値を保持します。 アドレスは、.balanceメソッドを使用して残高を取得するために使用でき、.transferメソッドを使用して残高を別のアドレスに転送するために使用できます。
address x = 0x212;
address myAddress = this;
if (x.balance < 10 && myAddress.balance >= 10) x.transfer(10);