Project

General

Profile

Actions

Feature #8994

open

add methods for Float to get if an NaN is quiet or not, also add class methods for Float to "generate" an quiet NaN and an loud NaN

Added by Hanmac (Hans Mackowiak) about 11 years ago. Updated about 5 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:57724]

Description

Currently its not easy possible to know of an NaN in ruby is silent or not

like Float::NAN.quiet?

there should also methods to make an new NaN like Float::quiet_nan, maybe with the possibility to set user data

also there is

[Float::NAN].pack("g") #=> "\x7F\xC0\x00\x00"
[0.0/0.0].pack("g") #=> "\xFF\xC0\x00\x00"

and

[-(0.0/0.0)].pack("g") #=> "\x7F\xC0\x00\x00"

so it seems that - can turn an quiet NaN into an loud one? (i am not 100% clear about that)
specially when using two different NaN in one operation like

[(0.0/0.0) + Float::NAN].pack("g") #=> "\xFF\xC0\x00\x00"
[Float::NAN + (0.0/0.0)].pack("g") #=> "\x7F\xC0\x00\x00"

Wikipedia says:
For example, a bit-wise IEEE floating-point standard single precision (32-bit) NaN would be: s111 1111 1axx xxxx xxxx xxxx xxxx xxxx where s is the sign (most often ignored in applications), a determines the type of NaN, and x is an extra payload (most often ignored in applications). If a = 1, it is a quiet NaN; if a is zero and the payload is nonzero, then it is a signaling NaN.

so it seems that the negation does it a bit wrong? i mean -@ should not change the value like that?

Actions

Also available in: Atom PDF

Like0
Like0