Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Darwin/Foundation-swiftoverlay-Tests/TestDecimal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class TestDecimal : XCTestCase {

let ulp = explicit.ulp
XCTAssertEqual(0x7f, ulp.exponent)
XCTAssertEqual(8, ulp._length)
XCTAssertEqual(1, ulp._length)
XCTAssertEqual(0, ulp._isNegative)
XCTAssertEqual(1, ulp._isCompact)
XCTAssertEqual(0, ulp._reserved)
Expand Down Expand Up @@ -588,6 +588,11 @@ class TestDecimal : XCTestCase {
}
}
}

func test_ULP() {
let x = 0.1 as Decimal
XCTAssertFalse(x.ulp > x)
}

func test_unconditionallyBridgeFromObjectiveC() {
XCTAssertEqual(Decimal(), Decimal._unconditionallyBridgeFromObjectiveC(nil))
Expand Down
2 changes: 1 addition & 1 deletion Darwin/Foundation-swiftoverlay/Decimal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ extension Decimal {
public var ulp: Decimal {
if !self.isFinite { return Decimal.nan }
return Decimal(
_exponent: _exponent, _length: 8, _isNegative: 0, _isCompact: 1,
_exponent: _exponent, _length: 1, _isNegative: 0, _isCompact: 1,
_reserved: 0, _mantissa: (0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000))
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Foundation/Decimal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ extension Decimal {
public var ulp: Decimal {
if !self.isFinite { return Decimal.nan }
return Decimal(
_exponent: _exponent, _length: 8, _isNegative: 0, _isCompact: 1,
_exponent: _exponent, _length: 1, _isNegative: 0, _isCompact: 1,
_reserved: 0, _mantissa: (0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000))
}

Expand Down
8 changes: 7 additions & 1 deletion Tests/Foundation/Tests/TestDecimal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class TestDecimal: XCTestCase {

let ulp = explicit.ulp
XCTAssertEqual(0x7f, ulp.exponent)
XCTAssertEqual(8, ulp._length)
XCTAssertEqual(1, ulp._length)
XCTAssertEqual(0, ulp._isNegative)
XCTAssertEqual(1, ulp._isCompact)
XCTAssertEqual(0, ulp._reserved)
Expand Down Expand Up @@ -851,6 +851,11 @@ class TestDecimal: XCTestCase {

XCTAssertEqual(100,number.objCType.pointee, "ObjC type for NSDecimalNumber is 'd'")
}

func test_ULP() {
let x = 0.1 as Decimal
XCTAssertFalse(x.ulp > x)
}

func test_ZeroPower() {
let six = NSDecimalNumber(integerLiteral: 6)
Expand Down Expand Up @@ -1457,6 +1462,7 @@ class TestDecimal: XCTestCase {
("test_ScanDecimal", test_ScanDecimal),
("test_SimpleMultiplication", test_SimpleMultiplication),
("test_SmallerNumbers", test_SmallerNumbers),
("test_ULP", test_ULP),
("test_ZeroPower", test_ZeroPower),
("test_parseDouble", test_parseDouble),
("test_doubleValue", test_doubleValue),
Expand Down