sint

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2019 License: Apache-2.0 Imports: 2 Imported by: 68

Documentation

Overview

Package sint is a basic math library for int.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(a int) int

func AlignUp

func AlignUp(v int, alignment int) int

func Byte

func Byte(i int) byte

func Clamp

func Clamp(x, min, max int) int

func Log10

func Log10(i int) int

Log10 returns the log10(i), rounded down to a whole integer. i must be positive.

Example
package main

import (
	"fmt"

	"github.com/google/gapid/core/math/sint"
)

func main() {
	for _, n := range []int{0, 1, 2, 9, 10, 11, 99, 100, 101} {
		fmt.Printf("Log10(%v): %v\n", n, sint.Log10(n))
	}
}
Output:

Log10(0): 0
Log10(1): 0
Log10(2): 0
Log10(9): 0
Log10(10): 1
Log10(11): 1
Log10(99): 1
Log10(100): 2
Log10(101): 2

func Max

func Max(a, b int) int

Max returns the maximum value of a and b.

func MaxOf

func MaxOf(a int, b ...int) int

MaxOf returns the maximum value of all the arguments.

func Min

func Min(a, b int) int

Min returns the minimum value of a and b.

func MinOf

func MinOf(a int, b ...int) int

MinOf returns the minimum value of all the arguments.

Types

type Histogram added in v1.2.0

type Histogram []int

Histogram represents a series of integer values, for the purpose of computing statistics about them.

func (*Histogram) Add added in v1.2.0

func (h *Histogram) Add(at, count int)

Add adds `count` to the Histogram at position `at`, zero-extending the Histogram if necessary.

func (*Histogram) Stats added in v1.2.0

func (h *Histogram) Stats() HistogramStats

Stats computes average, standard deviation, and median statistics on the values in the Histogram. See HistogramStats for more details.

type HistogramStats added in v1.2.0

type HistogramStats struct {
	// Average is the mean of all the values in the Histogram.
	Average float64
	// Stddev is the population standard deviation of the values in the
	// Histogram.
	Stddev float64
	// Median is the median value of the values in the Histogram.
	Median int
}

HistogramStats stores the result of computing statistics on a Histogram

Jump to

Keyboard shortcuts

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