knz / go-ilog10

Fast integer log10 in Go (number of decimal digits - 1)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-ilog10

Fast integer log10 in Go (number of decimal digits - 1)

Usage:

import "github.com/knz/go-ilog10"

func main() {
   fmt.Println(ilog10.FastUint32Log10(1234)) // prints 3
   fmt.Println(ilog10.NumInt32DecimalDigits(1234)) // prints 4

   fmt.Println(ilog10.FastUint64Log10(1234)) // prints 3
   fmt.Println(ilog10.NumInt64DecimalDigits(1234)) // prints 4
}

About

Fast integer log10 in Go (number of decimal digits - 1)

License:Apache License 2.0


Languages

Language:Go 100.0%