You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Results - Docker Official - Swift 4.2 ubuntu:16.04
Additional Detail from JIRA
Votes
0
Component/s
Foundation
Labels
Bug
Assignee
None
Priority
Medium
md5: 1fd45dd10d039996471fbbd9ab9b2857
Issue Description:
NumberFormatter().string(from:Decimal) returns the last element of the calc rather than 0.00. This happens in 4.1.3 and 4.2 Linux, but works fine on Mac OS.
Here is a simple test script that can be run on Mac OS and Linux with different results:
#!/usr/bin/swiftimportFoundationprint("Simple Test\nDecimal\t\tFormatted")
letnf = NumberFormatter()
nf.locale = Locale(identifier: "en_US")
nf.numberStyle = .decimalnf.minimumFractionDigits = 2nf.maximumFractionDigits = 2letx = Decimal(10.5)
lety = Decimal(9.0)
letz = Decimal(1.5)
leta = x - y - zletb = x - z - yprint("x=Decimal(10.5):Formatted \(nf.string(from: NSDecimalNumber(decimal:x)) ?? "")")
print("y=Decimal(9.0):\tFormatted \(nf.string(from: NSDecimalNumber(decimal:y)) ?? "")")
print("z=Decimal(1.5):\tFormatted \(nf.string(from: NSDecimalNumber(decimal:z)) ?? "")")
print("x - y - z = \(a):\tFormatted \(nf.string(from: NSDecimalNumber(decimal:a)) ?? "")")
print("x - z - y = \(b):\tFormatted \(nf.string(from: NSDecimalNumber(decimal:b)) ?? "")")
Results - Docker Official - Swift 4.2 ubuntu:16.04
SimpleTestDecimalFormattedx=Decimal(10.5):Formatted10.50y=Decimal(9.0): Formatted9.00z=Decimal(1.5): Formatted1.50x - y - z = 0: Formatted1.50x - z - y = 0: Formatted9.00
Results Swift 4.1.2 MacOS 10.13.6
SimpleTestDecimalFormattedx=Decimal(10.5):Formatted10.50y=Decimal(9.0): Formatted9.00z=Decimal(1.5): Formatted1.50x - y - z = 0: Formatted0.00x - z - y = 0: Formatted0.00
The text was updated successfully, but these errors were encountered:
$ ~/swift-DEVELOPMENT-SNAPSHOT-2018-11-13-a-ubuntu18.04/usr/bin/swiftsr_9269.swiftSimpleTestDecimalFormattedx=Decimal(10.5):Formatted10.50y=Decimal(9.0): Formatted9.00z=Decimal(1.5): Formatted1.50x - y - z = 0: Formatted0.00x - z - y = 0: Formatted0.00
Environment
Results - Docker Official - Swift 4.2 ubuntu:16.04
Additional Detail from JIRA
md5: 1fd45dd10d039996471fbbd9ab9b2857
Issue Description:
NumberFormatter().string(from:Decimal) returns the last element of the calc rather than 0.00. This happens in 4.1.3 and 4.2 Linux, but works fine on Mac OS.
Here is a simple test script that can be run on Mac OS and Linux with different results:
Results - Docker Official - Swift 4.2 ubuntu:16.04
Results Swift 4.1.2 MacOS 10.13.6
The text was updated successfully, but these errors were encountered: