Comments (5)
実数における一般的な切り上げ、切り捨て、四捨五入の要件を十分に満たしていると思いますが見当違いでしょうか?
- 切り捨て(floor):より小さい値に丸められる
- 切り上げ(ceil):より大きい値に丸められる
- 四捨五入(round):近い整数に丸められる
$ irb
irb(main):001:0> 12.0/5
=> 2.4
irb(main):002:0> -2.4.floor
=> -3
irb(main):003:0> -2.4.ceil
=> -2
irb(main):004:0> -2.4.round
=> -2
irb(main):005:0> 2.4.floor
=> 2
from bcdice.
定義によるところですが、あくまでfloorは床関数、ceilは天井関数であって、直接切り捨てや切り上げを指すものではないかもしれません。
参考:
from bcdice.
もともと C(1+2-3*4/5)
が期待される結果となっていないことから発覚したのですが、どう直していくところでしょうか?
期待される結果:
1 + 2 - 3 * 4 / 5 = (1 + 2) - ((3 * 4) / 5) = 3 - (12 / 5) = 3 - 2.4
-> 3 - 2 = 1
現在の挙動(推測):
1 + 2 - 3 * 4 / 5 = 3 - 3 * 4 / 5 = 3 + (-3) * 4 / 5 = 3 + (-12) / 5 = 3 + (-2.4)
-> 3 + (-3) = 0
from bcdice.
現在の挙動は、Rubyと同様に切り捨てをfloor、切り上げをceilと定義した場合と整合が取れているため問題ないと思っています。切り捨てと切り上げの定義を変更する必要があるのでしたら、理由を添えて提案をお願いします。
計算順序の方はまだ追いきれてないので、確認します。
from bcdice.
Rubyの動作をこちらでも確認してみました。
[1] pry(main)> # 整数同士の除算
[2] pry(main)> 12/5
=> 2
[3] pry(main)> (-12)/(-5)
=> 2
[4] pry(main)> -12/5
=> -3
[5] pry(main)> 12/(-5)
=> -3
[6] pry(main)> # 多項式の項の順番の変更
[7] pry(main)> 1+2-3*4/5
=> 1
# (1 + 2) - ((3 * 4) / 5) = 3 - 12 / 5 = 3 - 2 = 1
[8] pry(main)> -3*4/5+1+2
=> 0
# ((-3 * 4) / 5) + (1 + 2) = (-12 / 5) + 3 = -3 + 3 = 0
分かったことは、
- 現在の切り捨ておよび切り上げはそれぞれfloor、ceilで問題ない(Rubyと同じ挙動)
- 多項式の評価の仕方が異なる。どどんとふでは減算を負数の加算に変換しているため、多項式の評価結果が直感的でないものになる。
ということでした。結論として、 #61「計算処理の演算順序が不正」で対応するのが良さそうだと判断しました。
from bcdice.
Related Issues (20)
- ソード・ワールド系のi18n化
- ドラクルージュの抗い判定の改善
- Fate core system
- シノビガミのファンブル表が初期文庫版から改訂されている HOT 1
- [SwordWorld2.0] レーティング表部分の解析結果のリファクタリング
- [Cthulhu] RESの引数の挙動
- Proposal: Command::Parserの改善 HOT 2
- ビギニングアイドル新版の対応
- ゴブリンスレイヤーTRPGで大成功/大失敗の閾値を変数に
- 表類の誤植修正
- ワールドオブダークネスのバグ?
- エモクロアTRPGのi18n対応
- アリアンロッドRPGのi18n対応
- D66の並べ替え指定が小文字だと機能しない
- [CyberpunkRed] 判定が `>=` でなく `>`
- Codecovの移行
- スカイノーツ NEHの誤植
- エモクロアのヘルプメッセージを公式用語を使って整理する
- シノビガミのヘルプ誤植
- 『逆転計略TRPG 天才軍師になろう』の対応
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bcdice.