Skip to content

Commit

Permalink
Add Float64() and Float32() to hashhelper package
Browse files Browse the repository at this point in the history
  • Loading branch information
richardwilkes committed Sep 18, 2024
1 parent 51ac427 commit 3ef75c6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions xmath/hashhelper/hashhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package hashhelper

import (
"hash"
"math"
)

// String writes the given string to the hash.
Expand Down Expand Up @@ -67,3 +68,13 @@ func Bool[T ~bool](h hash.Hash, data T) {
}
_, _ = h.Write([]byte{b})
}

// Float64 writes the given 64-bit float to the hash.
func Float64[T ~float64](h hash.Hash, data T) {
Num64(h, math.Float64bits(float64(data)))
}

// Float32 writes the given 64-bit float to the hash.
func Float32[T ~float32](h hash.Hash, data T) {
Num32(h, math.Float32bits(float32(data)))
}

0 comments on commit 3ef75c6

Please sign in to comment.