SSブログ

SML#の整数除算のバグ [SML]

[2014/4/5追記] この記事に記載の事象はSML#2.0.0では修正されていることを確認しました。

SML#ではInt.divとInt.quotが同じ丸めを行っているようだ。

SML# version 1.2.0 (2012-11-14 18:25:26 JST) for x86-linux
# ~1 div 2;
val it = 0 : int
# Int.quot (~1, 2);
val it = 0 : int


SMLの仕様ではi div jは「returns the greatest integer less than or equal to the quotient of i by j」、Int.quotは「quot rounds towards zero」となっていて違う動作であるべきだ。

http://www.standardml.org/Basis/integer.html#SIG:INTEGER.div:VAL

他の処理系での結果。

Standard ML of New Jersey v110.74 [built: Mon Oct 29 11:48:41 2012]
- ~1 div 2;
val it = ~1 : int
- Int.quot (~1, 2);
[autoloading]
[library $SMLNJ-BASIS/basis.cm is stable]
[autoloading done]
val it = 0 : int

Poly/ML 5.2 Release
> ~1 div 2;
val it = ~1 : int
> Int.quot (~1, 2);
val it = 0 : Int.int

Moscow ML version 2.10
Enter `quit();' to quit.
- ~1 div 2;
> val it = ~1 : int
-  Int.quot (~1, 2);
> val it = 0 : int


modとremについても同様のようだ。

でもSML#のバグ報告先ってウェブサイト上には書いていなくてよくわからないけど…
nice!(0)  コメント(2)  トラックバック(0) 

nice! 0

コメント 2

eldesh

始めまして。
SML#のバグ報告は githubの非公式リポジトリ(https://github.com/smlsharp/smlsharp) のissueに登録するといいと思います。
中の人も見ているはずなので伝わります。把握しているが手がまわってない、という状態のようなので修正は気長に待つ必要がありますが(^^;;

by eldesh (2014-03-14 23:44) 

ether

コメントありがとうございます。

半公式みたいな感じなのでしょうかね?登録してみました。
by ether (2014-03-15 12:38) 

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

トラックバック 0

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。