ilog10

package module
v0.0.0-...-0a8343d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

README

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
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FastUint32Log10

func FastUint32Log10(v uint32) uint

FastUint32Log10 computes the integer base-10 logarithm of v, that is, the number of decimal digits in v minus one. The function is not well-defiend for v == 0.

func FastUint64Log10

func FastUint64Log10(v uint64) uint

FastUint64Log10 computes the integer base-10 logarithm of v, that is, the number of decimal digits in v minus one. The function is not well-defiend for v == 0.

func NumInt32DecimalDigits

func NumInt32DecimalDigits(n int32) uint

NumInt32DecimalDigits returns the number of decimal digits in n (excluding the negative sign, if any). 0 is considered to have one digit.

func NumInt64DecimalDigits

func NumInt64DecimalDigits(n int64) uint

NumInt64DecimalDigits returns the number of decimal digits in n (excluding the negative sign, if any). 0 is considered to have one digit.

func NumUint32DecimalDigits

func NumUint32DecimalDigits(n uint32) uint

NumUint32DecimalDigits returns the number of decimal digits in n (excluding the negative sign, if any). 0 is considered to have one digit.

func NumUint64DecimalDigits

func NumUint64DecimalDigits(n uint64) uint

NumUint64DecimalDigits returns the number of decimal digits in n (excluding the negative sign, if any). 0 is considered to have one digit.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL