Skip to content

Instantly share code, notes, and snippets.

@codegold79
Created October 2, 2020 02:30
Show Gist options
  • Select an option

  • Save codegold79/aeafe489853f28bb842d2aae9b001063 to your computer and use it in GitHub Desktop.

Select an option

Save codegold79/aeafe489853f28bb842d2aae9b001063 to your computer and use it in GitHub Desktop.
func incMemVal(mem float64) string {
// 2^13 = 8192. 8GB is max RAM.
maxExp := 13
newMem := 1 << maxExp
exp := int(math.Round(math.Log10(mem) / math.Log10(2)))
exp++
if exp < maxExp {
newMem = 1 << exp
}
return strconv.Itoa(newMem)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment