yosshi4486 / SternBrocotTreeSwift

MIT License
0 stars 0 forks source link

Reduce comparison costs? #54

Closed yosshi4486 closed 3 years ago

yosshi4486 commented 3 years ago

Idea

if compare ad < bc

this does same task, but it possibly treats smaller numbers than above.

let commonFactor = gcd(b, d)
let smallB = b / commonFactor
let smallD = d / commonFactor
let ad = a * smallD
let bc = smallB * c
return ad < bc