processing / processing/libprocessing

Discrepancy: number comparison differs from Processing Java `(0.1 + 0.2 == 0.3)`

未關閉
#203 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Rust
星號
69
分支
14
平均合併
15 天 22 小時
30 天內合併 PR
3

描述

I don't know whether this is something that needs to be addressed or just documented.
I suppose this is related to the difference between float and double precision (?)

In Processing, this condition evaluates to true:

void setup() {
  size(400, 400);

  if (0.1 + 0.2 == 0.3) {
    background(0, 255, 0);
    circle(200, 200, 100);
  }
}

The equivalent mewnala sketch evaluates the condition as false.

from mewnala import *

def setup():
    size(200, 200)

    if 0.1 + 0.2 == 0.3:
        background(0, 255, 0)
        circle(200, 200, 100)

run()

Note: size is reduced in mewnala to account for https://github.com/processing/libprocessing/issues/198

Image

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

執行提供的 Processing Java 和 mewnala Python 草圖,以確認結果存在差異。接著追蹤 Rust 實作中的數值求值行為,並判斷應修正還是記錄這項差異,同時透過測試或文件更新定義預期行為。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
java, python, rust
領域
backend
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
冷清
描述清晰度
需要釐清
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。