Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-1464] NSNumber.description is not compatible between OS X and linux #4155

Closed
norio-nomura opened this issue May 10, 2016 · 5 comments
Closed

Comments

@norio-nomura
Copy link
Contributor

Previous ID SR-1464
Radar None
Original Reporter @norio-nomura
Type Bug
Status Resolved
Resolution Done
Environment

swift-DEVELOPMENT-SNAPSHOT-2016-05-09-a
OS X 10.11.4 (15E65)
Ubuntu 14.04

Additional Detail from JIRA
Votes 1
Component/s Foundation
Labels Bug, Linux
Assignee None
Priority Medium

md5: 60bfdbad742f50ecf9595cbf5c19db84

Issue Description:

Using swift-DEVELOPMENT-SNAPSHOT-2016-05-09-a.
On OS X:

Welcome to Apple Swift version 3.0-dev (LLVM dffa09ffd8, Clang 9f0d189820, Swift 1c720b8f84). Type :help for assistance.
  1> import Foundation 
  2> let n = NSNumber(value: 0.001) 
n: NSNumber = Double(0.001)
  3> n.description 
$R0: String = "0.001"
  4>  

On Ubuntu 14.04:

Welcome to Swift version 3.0-dev (LLVM dffa09ffd8, Clang 9f0d189820, Swift 1c720b8f84). Type :help for assistance.
  1> import Foundation
  2> let n = NSNumber(value:0.001)
n: Foundation.NSNumber = {
  Foundation.NSValue = {
    Foundation.NSObject = {}
  }
  _base = {
    info = 5766
    pad = 0
  }
  _pad = 4562254508917369340
}
  3> n.description
$R0: String = ".001"
  4>  

OS X: "0.001"
Linux: ".001"

@phausler
Copy link
Member

On Darwin the objc behavior is based on `-[NSString initWithFormat:locale:]` for NSNumber.

objCType format
B, c @"%d"
C @"%u"
s @"%hi"
S @"%hu"
i @"%d"
I @"%u"
l @"%ld"
L @"%lu"
f @"%0.7g"
d @"%0.16g"
q @"%lld"
Q @"%llu"

@Dante-Broggi
Copy link

Is this resolved? If so, this should be closed.

@norio-nomura
Copy link
Contributor Author

Still exists on Swift 4.2

$ docker run --privileged -it --rm norionomura/swift:42 swift
Welcome to Swift version 4.2 (swift-4.2-RELEASE). Type :help for assistance.
  1> import Foundation
  2> let n = NSNumber(value: 0.001) 
n: Foundation.NSNumber = {
  Foundation.NSValue = {
    Foundation.NSObject = {}
  }
  _base = {
    info = 832702464
    pad = 8388596
  }
  _pad = 36028746312058880
}
  3> n.description
$R0: String = ".001"
  4>  

@spevans
Copy link
Collaborator

spevans commented Oct 14, 2018

#1724

@spevans
Copy link
Collaborator

spevans commented Dec 12, 2018

This should be fixed now

$ cat sr_1464.swift 
import Foundation
let n = NSNumber(value:0.001)
print(n.description)

$ ~/swift-DEVELOPMENT-SNAPSHOT-2018-12-07-a-ubuntu18.04/usr/bin/swift sr_1464.swift 
0.001
$  

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants