-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
additionoh, so shiny!oh, so shiny!brrrsuch code, much wowsuch code, much wowsubtractionhuh? where did it go?huh? where did it go?
Milestone
Description
I can return equal hash values for all binary integers with equal values:
I'm (un)reasonably pleased with this unification ( π π β¨ ).
The (#101) approach does not work past 64 bits.
Infinite and negative values collide but that's OK.
#expect(random.hashValue == IXL(load: random).hashValue)
#expect(random.hashValue == UXL(load: random).hashValue)extension BinaryInteger {
@inlinable public func hash(into hasher: inout Swift.Hasher) {
self.withUnsafeBinaryIntegerElements(as: U8.self) {
hasher.combine(bytes: $0.normalized().body.bytes())
hasher.combine($0.appendix)
}
}
}Metadata
Metadata
Assignees
Labels
additionoh, so shiny!oh, so shiny!brrrsuch code, much wowsuch code, much wowsubtractionhuh? where did it go?huh? where did it go?