Skip to content

Commit

Permalink
Avoid division in genFloat01()
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingmutant committed Jul 20, 2021
1 parent ce9c50f commit ef97f65
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module pgregory.net/rapid

go 1.12
go 1.14
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func bitmask64(n uint) uint64 {
}

func genFloat01(s bitStream) float64 {
return float64(s.drawBits(53)) / (1 << 53)
return float64(s.drawBits(53)) * 0x1.0p-53
}

func genGeom(s bitStream, p float64) uint64 {
Expand Down

0 comments on commit ef97f65

Please sign in to comment.