Uploaded image for project: 'Swift'
  1. Swift
  2. SR-2626

String to Double conversion fails on "snan" input

    XMLWordPrintable

    Details

      Description

      The string -> floating-point intializer doesn’t allow you to create signaling NaN values. In the following code, y == nil, but should have the same value as x:

      let x = Double(nan: 0, signaling: true) // OK
      let y = Double("snan") // nil
      

      This relates to section 5.12.1 of IEEE 754:

      Conversion of an external character sequence “snan” (regardless of case) with an optional preceding sign, to a supported format should either produce a signaling NaN or else produce a quiet NaN and signal the invalid operation exception.

        Attachments

          Activity

            People

            • Assignee:
              hartbit David Hart
              Reporter:
              gribozavr Dmitri Gribenko
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: