Skip to content

[SR-3131] String(someDouble) incorrectly switches to scientific notation for large integers #45719

Closed as duplicate of#42728
@lilyball

Description

@lilyball
mannequin
Previous ID SR-3131
Radar None
Original Reporter @lilyball
Type Bug
Status Resolved
Resolution Done
Environment

Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee @tbkka
Priority Medium

md5: 1b1ce68db85995c555c91183810f4d55

duplicates:

Issue Description:

The string representation of a Double incorrectly uses scientific notation for large integers that are still within the range that can be precisely represented using a Double. This happens at some point between 1 << 49 and 1 << 50.

Example:

  1> Double(1 << 50)
$R0: Double = 1125899906842624
  2> Double(1 << 50).ulp
$R1: Double = 0.25
  3> print(Double(1 << 50))
1.12589990684262e+15

Metadata

Metadata

Assignees

Labels

CustomStringConvertibleArea → standard library: The `CustomStringConvertible` protocolDoubleArea → standard library: The `Double` typebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.standard libraryArea: Standard library umbrellaswift 3.0unexpected behaviorBug: Unexpected behavior or incorrect output

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions