Project

General

Profile

Actions

Bug #20662

closed

pack("g") completely discards any actual NaN value and always packs the same single-precision bytes for a NaN

Added by cabo (Carsten Bormann) 3 months ago. Updated 3 months ago.

Status:
Feedback
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.4 (2024-07-09 revision be1089c8ec) [arm64-darwin23]
[ruby-core:118779]

Description

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.rb Program for demonstrating the bugs cabo (Carsten Bormann), 08/02/2024 03:16 PM
showbug-arm.txt (5.48 KB) showbug-arm.txt Output for 3.3.4/arm64-darwin23 cabo (Carsten Bormann), 08/02/2024 03:16 PM
showbug-intel.txt (5.48 KB) showbug-intel.txt Output for 3.3.4/x86_64-darwin19 cabo (Carsten Bormann), 08/02/2024 03:19 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0