Skip to content

[216_7] 添加跨平台数值比较行为不一致的调研记录#723

Open
da-liii wants to merge 1 commit intomainfrom
da/216_7/eq_sign
Open

[216_7] 添加跨平台数值比较行为不一致的调研记录#723
da-liii wants to merge 1 commit intomainfrom
da/216_7/eq_sign

Conversation

@da-liii
Copy link
Copy Markdown
Contributor

@da-liii da-liii commented Apr 23, 2026

摘要

tests/scheme/base/eq-sign-test.scm 中发现跨平台数值比较行为不一致的问题,添加调研记录到开发文档。

问题描述

(= 1/3 0.3333333333333333) 在不同平台上行为不一致:

  • Linux:正确返回 #f
  • macOS/Windows:错误返回 #t

根本原因

S7 Scheme 在比较有理数和浮点数时,使用 long_double 将有理数转换为浮点数后比较。不同平台上 long double 的精度不同:

  • Linux:80/128 位扩展精度
  • macOS/Windows:64 位(与 double 相同)

相关代码

  • src/s7.c:18957: 数值比较逻辑
  • src/s7.c:3755: fraction 宏定义

状态

当前通过 (os-linux?) 在测试中进行平台适配,根本问题需 S7 Scheme 层面修复。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant