humanround

package module
v0.0.0-...-e5a91f5 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 1 Imported by: 0

README

humanround is a simple Go package that tries to round human-scale numbers to more "human" values. For example, rather than rounding 50.8 to 51, it rounds it to 50. The precision varies by the size of the number, and unit idiosyncracies are accounted for (ie inches get rounded to halves/quarters/eighths, depending on their size).

See https://pkg.go.dev/github.com/reillywatson/humanround for documentation.

Documentation

Overview

package humanround applies heuristic rules to round numbers to a more "human" value.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Round

func Round(f float64, options ...Option) float64

Round rounds f to a more human-readable number. Its heuristics depend on the size of the number, and the provided options. It's intended for "human-scale" numbers, ie numbers that might plausibly be used to describe a human.

Types

type Option

type Option func(o *opts)

func WithUnit

func WithUnit(unit Unit) Option

type Unit

type Unit string
const Inch Unit = "inch"

Jump to

Keyboard shortcuts

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