[ruby-core:118836] [Ruby master Bug#20662] pack("g") completely discards any actual NaN value and always packs the same single-precision bytes for a NaN
From:
"nobu (Nobuyoshi Nakada) via ruby-core" <ruby-core@...>
Date:
2024-08-13 03:35:27 UTC
List:
ruby-core #118836
Issue #20662 has been updated by nobu (Nobuyoshi Nakada).
Status changed from Open to Feedback
I'm curious about your use case.
For what purpose and how do you want to use it?
----------------------------------------
Bug #20662: pack("g") completely discards any actual NaN value and always packs the same single-precision bytes for a NaN
https://bugs.ruby-lang.org/issues/20662#change-109400
* Author: cabo (Carsten Bormann)
* Status: Feedback
* ruby -v: ruby 3.3.4 (2024-07-09 revision be1089c8ec) [arm64-darwin23]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
`pack("G")`/`unpack("G")` works great with NaN values. However,
- `pack("g")` completely discards any actual NaN value and always packs the same bytes for a NaN
("bug as implemented" in `VALUE_to_float`)
Also:
- `unpack("g")` always sets the quiet bit to 1 in the `Float` result
(location of bug not obvious to me)
---Files--------------------------------
showbug.rb (3.21 KB)
showbug-arm.txt (5.48 KB)
showbug-intel.txt (5.48 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/