math

package
v0.6.5-rc33 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: EPL-1.0 Imports: 5 Imported by: 0

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 SubtractExact

func SubtractExact(a, b any) any

func ToIntExact

func ToIntExact(x any) any

Types

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