stringify infinites and NaN

This commit is contained in:
Gwenhael Le Moine 2022-02-09 16:28:35 +01:00
parent 4413146f52
commit 922ecf1bb6
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

View file

@ -75,12 +75,18 @@ module Rpl
"0#{elt[:base]}_"
end
if elt[:value].infinite?
suffix = elt[:value].infinite?.positive? ? '∞' : '-∞'
elsif elt[:value].nan?
suffix = '<NaN>'
else
suffix = if elt[:value].to_i == elt[:value]
elt[:value].to_i
else
elt[:value].to_s('F')
end
suffix = elt[:value].to_s( elt[:base] ) unless elt[:base] == 10
end
"#{prefix}#{suffix}"
when :list