Skip to content

[SR-2626] String to Double conversion fails on "snan" input #45231

@gribozavr

Description

@gribozavr
Previous ID SR-2626
Radar rdar://problem/26720376
Original Reporter @gribozavr
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, StarterBug
Assignee @hartbit
Priority Medium

md5: ba2c6f38b18ec9c711fa49aecc0453e6

Issue 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.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.good first issueGood for newcomersstandard libraryArea: Standard library umbrella

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions