Skip to content

Commit

Permalink
Replace x * x + y * y with hypot(x, y)
Browse files Browse the repository at this point in the history
  • Loading branch information
koher committed May 3, 2020
1 parent 9f4d2c4 commit 9feb2ea
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/CGPointVector/CGPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extension CGPoint {
}

public var length: CGFloat {
return sqrt(squareLength)
return hypot(x, y)
}

public var squareLength: CGFloat {
Expand Down
2 changes: 1 addition & 1 deletion Sources/CGPointVector/CGSize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extension CGSize {
}

public var length: CGFloat {
return sqrt(squareLength)
return hypot(width, height)
}

public var squareLength: CGFloat {
Expand Down
2 changes: 1 addition & 1 deletion Sources/CGPointVector/CGVector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extension CGVector {
}

public var length: CGFloat {
return sqrt(squareLength)
return hypot(dx, dy)
}

public var squareLength: CGFloat {
Expand Down

0 comments on commit 9feb2ea

Please sign in to comment.