Skip to content

Commit

Permalink
Removed Float80 from ARM64 targets
Browse files Browse the repository at this point in the history
  • Loading branch information
orchetect committed Oct 5, 2020
1 parent 8290689 commit 01b3475
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 28 deletions.
25 changes: 13 additions & 12 deletions Sources/OTCore/Swift Extensions/FloatingPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ extension Float: FloatingPointPower {
}
}

// Float80 seems to be deprecated as of the introduction of ARM64

//extension Float80: FloatingPointPower {
// /// OTCore:
// /// Convenience method for pow()
// public func power(_ exponent: Float80) -> Float80 {
// powl(self, exponent)
// }
//}
#if !arch(arm64) // Float80 is removed for ARM64
extension Float80: FloatingPointPower {
/// OTCore:
/// Convenience method for pow()
public func power(_ exponent: Float80) -> Float80 {
powl(self, exponent)
}
}
#endif

extension CGFloat: FloatingPointPower {
/// OTCore:
Expand Down Expand Up @@ -325,9 +325,10 @@ extension StringProtocol {
/// OTCore: Convenience method to return a Float
public var float: Float? { Float(self) }

// Float80 is removed for ARM64
// /// OTCore: Convenience method to return a Float80
// public var float80: Float80? { Float80(self) }
#if !arch(arm64) // Float80 is removed for ARM64
/// OTCore: Convenience method to return a Float80
public var float80: Float80? { Float80(self) }
#endif

/// OTCore: Convenience method to return a Decimal
public var decimal: Decimal? { Decimal(string: String(self)) }
Expand Down
7 changes: 4 additions & 3 deletions Sources/OTCore/Swift Extensions/Integers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ extension BinaryInteger {
/// OTCore: Convenience method to return a Float32
public var float32: Float32 { return Float32(self) }

// Float80 is removed for ARM64
// /// OTCore: Convenience method to return a Float80
// public var float80: Float80 { return Float80(self) }
#if !arch(arm64) // Float80 is removed for ARM64
/// OTCore: Convenience method to return a Float80
public var float80: Float80 { return Float80(self) }
#endif

/// OTCore: Convenience method to return a CGFloat
public var cgFloat: CGFloat { return CGFloat(self) }
Expand Down
4 changes: 4 additions & 0 deletions Sources/OTCore/Swift Extensions/NSAttributedString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2020 Steffan Andrews. All rights reserved.
//

#if os(macOS)
import Cocoa
#else
import UIKit
#endif

extension NSAttributedString {

Expand Down
2 changes: 1 addition & 1 deletion Sources/OTCore/Swift Extensions/URL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ extension FileManager {
/// Backwards compatible method for retrieving a temporary folder from the system.
public static var temporaryDirectoryCompat: URL {

if #available(OSX 10.12, *) {
if #available(OSX 10.12, iOS 10.0, *) {
return FileManager.default.temporaryDirectory
} else {
return URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
Expand Down
26 changes: 24 additions & 2 deletions Tests/OTCoreTests/Swift Extensions/FloatingPoint Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class Extensions_FloatingPoint_Tests: XCTestCase {

// Float80

#if !arch(arm64) // Float80 is removed for ARM64

let float80 = Float80(123.456)

_ = float80.int
Expand Down Expand Up @@ -103,6 +105,8 @@ class Extensions_FloatingPoint_Tests: XCTestCase {
_ = float80.uint64
_ = float80.uint64Exactly

#endif

// CGFloat

let cgfloat = CGFloat(123.456)
Expand Down Expand Up @@ -153,7 +157,11 @@ class Extensions_FloatingPoint_Tests: XCTestCase {
var b: Bool = false
b = 0.0.boolValue
b = Float(1).boolValue

#if !arch(arm64) // Float80 is removed for ARM64
b = Float80(1).boolValue
#endif

b = CGFloat(1).boolValue
b = Decimal(1).boolValue
_ = b // silences 'variable was written to, but never read' warning
Expand All @@ -169,7 +177,9 @@ class Extensions_FloatingPoint_Tests: XCTestCase {

XCTAssertEqual( 2.0.power(3) , 8.0) // Double
XCTAssertEqual( Float(2.0).power(3) , 8.0)
//XCTAssertEqual(Float80(2.0).power(3) , 8.0)
#if !arch(arm64) // Float80 is removed for ARM64
XCTAssertEqual(Float80(2.0).power(3) , 8.0)
#endif
XCTAssertEqual(CGFloat(2.0).power(3) , 8.0)
XCTAssertEqual(Decimal(2.0).power(3) , 8.0)

Expand Down Expand Up @@ -296,13 +306,21 @@ class Extensions_FloatingPoint_Tests: XCTestCase {
var str: String = ""
str = 0.0.string
str = Float(1).string

#if !arch(arm64) // Float80 is removed for ARM64
str = Float80(1).string
#endif

str = CGFloat(1).string
str = Decimal(1).string
_ = str // silences 'variable was written to, but never read' warning

XCTAssertEqual( Float(1).string, "1.0")

#if !arch(arm64) // Float80 is removed for ARM64
XCTAssertEqual(Float80(1).string, "1.0")
#endif

XCTAssertEqual(CGFloat(1).string, "1.0")
XCTAssertEqual(Decimal(1).string, "1")

Expand All @@ -312,7 +330,11 @@ class Extensions_FloatingPoint_Tests: XCTestCase {

XCTAssertEqual("1.0".double, 1.0)
XCTAssertEqual("1.0".float, 1.0)
//XCTAssertEqual("1.0".float80, 1.0)

#if !arch(arm64) // Float80 is removed for ARM64
XCTAssertEqual("1.0".float80, 1.0)
#endif

XCTAssertEqual("1.0".decimal, 1.0)

}
Expand Down
40 changes: 30 additions & 10 deletions Tests/OTCoreTests/Swift Extensions/Integers Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class Extensions_Integers_Tests: XCTestCase {
_ = 1.double
_ = 1.float
_ = 1.float32
//_ = 1.float80
#if !arch(arm64) // Float80 is removed for ARM64
_ = 1.float80
#endif
_ = 1.cgFloat
_ = 1.decimal

Expand All @@ -52,7 +54,9 @@ class Extensions_Integers_Tests: XCTestCase {
_ = UInt(1).double
_ = UInt(1).float
_ = UInt(1).float32
//_ = UInt(1).float80
#if !arch(arm64) // Float80 is removed for ARM64
_ = UInt(1).float80
#endif
_ = UInt(1).cgFloat
_ = UInt(1).decimal

Expand All @@ -72,7 +76,9 @@ class Extensions_Integers_Tests: XCTestCase {
_ = Int8(1).double
_ = Int8(1).float
_ = Int8(1).float32
//_ = Int8(1).float80
#if !arch(arm64) // Float80 is removed for ARM64
_ = Int8(1).float80
#endif
_ = Int8(1).cgFloat
_ = Int8(1).decimal

Expand All @@ -92,7 +98,9 @@ class Extensions_Integers_Tests: XCTestCase {
_ = UInt8(1).double
_ = UInt8(1).float
_ = UInt8(1).float32
//_ = UInt8(1).float80
#if !arch(arm64) // Float80 is removed for ARM64
_ = UInt8(1).float80
#endif
_ = UInt8(1).cgFloat
_ = UInt8(1).decimal

Expand All @@ -112,7 +120,9 @@ class Extensions_Integers_Tests: XCTestCase {
_ = Int16(1).double
_ = Int16(1).float
_ = Int16(1).float32
//_ = Int16(1).float80
#if !arch(arm64) // Float80 is removed for ARM64
_ = Int16(1).float80
#endif
_ = Int16(1).cgFloat
_ = Int16(1).decimal

Expand All @@ -132,7 +142,9 @@ class Extensions_Integers_Tests: XCTestCase {
_ = UInt16(1).double
_ = UInt16(1).float
_ = UInt16(1).float32
//_ = UInt16(1).float80
#if !arch(arm64) // Float80 is removed for ARM64
_ = UInt16(1).float80
#endif
_ = UInt16(1).cgFloat
_ = UInt16(1).decimal

Expand All @@ -152,7 +164,9 @@ class Extensions_Integers_Tests: XCTestCase {
_ = Int32(1).double
_ = Int32(1).float
_ = Int32(1).float32
//_ = Int32(1).float80
#if !arch(arm64) // Float80 is removed for ARM64
_ = Int32(1).float80
#endif
_ = Int32(1).cgFloat
_ = Int32(1).decimal

Expand All @@ -172,7 +186,9 @@ class Extensions_Integers_Tests: XCTestCase {
_ = UInt32(1).double
_ = UInt32(1).float
_ = UInt32(1).float32
//_ = UInt32(1).float80
#if !arch(arm64) // Float80 is removed for ARM64
_ = UInt32(1).float80
#endif
_ = UInt32(1).cgFloat
_ = UInt32(1).decimal

Expand All @@ -192,7 +208,9 @@ class Extensions_Integers_Tests: XCTestCase {
_ = Int64(1).double
_ = Int64(1).float
_ = Int64(1).float32
//_ = Int64(1).float80
#if !arch(arm64) // Float80 is removed for ARM64
_ = Int64(1).float80
#endif
_ = Int64(1).cgFloat
_ = Int64(1).decimal

Expand All @@ -212,7 +230,9 @@ class Extensions_Integers_Tests: XCTestCase {
_ = UInt64(1).double
_ = UInt64(1).float
_ = UInt64(1).float32
//_ = UInt64(1).float80
#if !arch(arm64) // Float80 is removed for ARM64
_ = UInt64(1).float80
#endif
_ = UInt64(1).cgFloat
_ = UInt64(1).decimal

Expand Down
3 changes: 3 additions & 0 deletions Tests/OTCoreTests/Swift Extensions/Operators Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ class Extensions_Operators_Tests: XCTestCase {

XCTAssertEqual( 43.0 % 10.0, 3.0)
XCTAssertEqual( Float(43.0) % 10.0, 3.0)

#if !arch(arm64)
XCTAssertEqual(Float80(43.0) % 10.0, 3.0)
#endif

// CGFloat

Expand Down

0 comments on commit 01b3475

Please sign in to comment.