math

package
v0.7.7 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: EPL-1.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package math exposes JVM-faithful java.lang.Math equivalents for code running on glojure. Each symbol is published two ways:

  • as a Go package-level value (used when gloat AOT-compiles a Clojure call site to a direct Go reference such as `compatmath.Sqrt`); and
  • through glojure's pkgmap (used by the REPL and any dynamic resolution path).

Java's Math methods are overloaded by argument type (int, long, float, double). The polymorphic helpers here type-switch on the runtime argument and dispatch to the matching gojava overload, returning a Go value whose type mirrors what the JVM would have produced for the same call.

Index

Constants

This section is empty.

Variables

View Source
var (
	PI = jmath.PI
	E  = jmath.E
)
View Source
var (
	Sqrt      = jmath.Sqrt
	Cbrt      = jmath.Cbrt
	Sin       = jmath.Sin
	Cos       = jmath.Cos
	Tan       = jmath.Tan
	Asin      = jmath.Asin
	Acos      = jmath.Acos
	Atan      = jmath.Atan
	Sinh      = jmath.Sinh
	Cosh      = jmath.Cosh
	Tanh      = jmath.Tanh
	Log       = jmath.Log
	Log10     = jmath.Log10
	Log1p     = jmath.Log1p
	Exp       = jmath.Exp
	Expm1     = jmath.Expm1
	Ceil      = jmath.Ceil
	Floor     = jmath.Floor
	Rint      = jmath.Rint
	Signum    = jmath.Signum
	ToRadians = jmath.ToRadians
	ToDegrees = jmath.ToDegrees
)
View Source
var (
	Pow           = jmath.Pow
	Atan2         = jmath.Atan2
	CopySign      = jmath.CopySign
	Hypot         = jmath.Hypot
	IEEEremainder = jmath.IEEEremainder
)
View Source
var Random = jmath.Random
View Source
var Round = jmath.Round

Functions

func Abs

func Abs(x any) any

func AddExact

func AddExact(a, b any) any

func DecrementExact

func DecrementExact(x any) any

func FloorDiv

func FloorDiv(a, b any) any

func FloorMod

func FloorMod(a, b any) any

func IncrementExact

func IncrementExact(x any) any

func Max

func Max(a, b any) any

func Min

func Min(a, b any) any

func MultiplyExact

func MultiplyExact(a, b any) any

func NegateExact

func NegateExact(x any) any

func NewJavaRandom added in v0.7.6

func NewJavaRandom(args ...any) any

func SubtractExact

func SubtractExact(a, b any) any

func ToIntExact

func ToIntExact(x any) any

Types

type JavaRandom added in v0.7.6

type JavaRandom struct {
	// contains filtered or unexported fields
}

JavaRandom provides the small java.util.Random instance surface used by clojure.data.generators and other portable libraries.

func (*JavaRandom) NextBoolean added in v0.7.6

func (r *JavaRandom) NextBoolean() bool

func (*JavaRandom) NextDouble added in v0.7.6

func (r *JavaRandom) NextDouble() float64

func (*JavaRandom) NextFloat added in v0.7.6

func (r *JavaRandom) NextFloat() float32

func (*JavaRandom) NextLong added in v0.7.6

func (r *JavaRandom) NextLong() int64

type Math

type Math struct{}

Math is the placeholder type registered as java.lang.Math's reflect.Type. java.lang.Math is final with a private constructor in the JVM, so no instances ever exist; the value here only needs to make (instance? Class Math) succeed so (ns-imports *ns*) sees the import.

Jump to

Keyboard shortcuts

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