sgn

符号

val = sgn(p1)

p1 : 符号を判定する値(数値)

(プラグイン / モジュール : hspmath)

解説

数値の符号を判定し、正ならば1を・負ならば-1を・ゼロならば0を返します。

サンプル

#include "hspmath.as"
	tmp = 10
	sign = sgn(tmp)
	if sign == 1 {
		mes str(tmp) + "は正です。"
	} else : if sign == -1 {
		mes str(tmp) + "は負です。"
	} else {
		mes str(tmp) + "はゼロです。"
	}
	stop

情報

プラグイン / モジュールhspmath
バージョン3.4
作成日2011/05/10
著作者HSPWiki
備考hspmath.asをインクルードすること。
タイプユーザー定義マクロ
グループ数学関数
対応環境
  • Windows 版 HSP
  • Macintosh 版 HSP
  • コマンドライン版 HSP
  • HSPLet
hs ファイルhsphelp\hspmath.hs