Unexpected results converting finite `decimal128_t` to `double`

Aperta
#1,568 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
22/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c, cpp
Ambito
cli, data

Direzione di ricerca

The conversion is the static_cast<double> operator on decimal128_t in the boost/decimal headers; locate it with a search for the conversion operator and the decimal128_t type. Reproduce by casting the six listed inputs and comparing against the expected doubles in the table. Done means all six cases match IEEE round-to-nearest-even results, including the overflow to infinity, the underflow to signed zero, and the subnormal case.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

static_cast<double>(boost::decimal::decimal128_t) gives the following results on a binary64 platform with round-to-nearest, ties-to-even. All six inputs are finite and exactly representable in decimal128_t:

Exact input Expected double Actual double
1e1000 +∞ +0
-1e1000 −∞ +0
-1e-1000 −0 +0
5e-324 0x0.0000000000001p-1022 +0
9007199254740993 9007199254740992 9007199254740994
1.0000000000000001111 0x1.0000000000001p+0 1.0

The last two cases distinguish two rounding errors:

  • 9007199254740993 is exactly halfway between adjacent doubles; the lower neighbor has even significand and should be selected.
  • 1.0000000000000001111 is strictly above the midpoint between 1.0 and its successor, so it should round up irrespective of the tie-breaking rule.

All six cases failed identically with Boost 1.92.0, master at 1f199e5, and develop at 215bbf0, using Apple Clang 21.0.0 on arm64 macOS 26.7.2.

Lingua principale
C++
Stelle
67
Fork
16
Merge medio
1g 15h
PR unite (30g)
12

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di boostorg/decimal

Tutte le issue di boostorg/decimal

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.