[Bug]: INT() truncates negative numbers instead of rounding them down

オープン 初心者向け
#1,881 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript
領域
backend, data

調査の方向性

issueで特定されている RoundingPlugin.intFunc から始め、INT の丸め動作に関する近くのテストを調べてください。正の値と整数に加えて、=INT(-2.5)、=INT(-8.9)、=INT(-0.1) のケースを確認してください。完了条件は、負の入力が期待される整数に切り下げられ、既存の正の値と整数の動作が引き続き正しいことです。

索引モデルが issue の本文から書いたものです。

説明

Description

INT rounds negative numbers toward zero:

Formula HyperFormula 3.5.0 Excel / Google Sheets / LibreOffice
=INT(-2.5) -2 -3
=INT(-8.9) -8 -9
=INT(-0.1) 0 -1

Excel's documentation uses =INT(-8.9) = -9 as its example ("Rounds a number down to the nearest integer"), and OpenFormula defines INT the same way. Positive numbers and integers are fine.

RoundingPlugin.intFunc (develop 5a6eb09) returns -Math.floor(-x) for negative input, which is truncation; Math.floor(x) gives the expected result for both signs.

Any sheet that splits a negative amount with INT (whole units vs remainder, e.g. A1-INT(A1)) gets a different result than it does in Excel.

Video or screenshots

No response

Demo
const hf = HyperFormula.buildFromArray([['=INT(-2.5)']], { licenseKey: 'gpl-v3' })
hf.getCellValue({ sheet: 0, row: 0, col: 0 }) // -2, expected -3
HyperFormula version

3.5.0

Your framework

None (plain Node.js)

Your environment

Node.js 24, Linux x64

主要言語
TypeScript
スター
2.8k
フォーク
175
平均マージ
2日 8時間
マージ済み PR(30日)
21

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

handsontable/hyperformula のほかの issue

handsontable/hyperformula の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。