整数を格納する、Integerの使い方について解説します。


グラスホッパー上では上の2つのどちらかで表されます。
整数を格納する
Integerを使うことで、整数を格納することができます。

左側の端子に、整数を入力します。
すると、整数がIntegerに格納されます。

整数なので、マイナスの負の数値も格納することができます。
小数を整数に四捨五入する
小数をIntegerにつなげることで、整数に四捨五入することができます。

小数の数値を整数に入力すると、上の画像のように四捨五入します。
しかし、全て整数に四捨五入してしまうので、小数点の位を指定して四捨五入することはできません。
小数点の位を指定して四捨五入したい場合は、ExpressionのRound関数を使って四捨五入をしてください。
ブール値(論理値)のTrueとFalseを数値に変換する
ブール値(論理値)のTrueとFalseを、数値に変換することもできます。

このように、TrueとFalseをIntegerにつなげます。
すると、Trueは1、Falseは0に変換されます。
コンポーネントに直接整数を指定する
コンポーネントに直接整数を指定することもできます。

1つの整数を直接指定する場合、Integerを右クリックし、Set Integerを選択します。
その後、1つの整数を入力し、Commit changesをクリックします。

複数の整数を直接指定する場合、左端子を右クリックし、Set Multiple Integersを選択します。
その後、複数の整数を入力し、Commit changesをクリックします。
Integerコンポーネントを使用しているグラスホッパー記事はこちら↓
Comment