Various helpful mathematical functions
This module includes, and is a superset of the built-in Lua math library so it is safe to do something like the following in your own code and still have access to both libraries:
local math = require("hs.math")
local n = math.sin(math.minFloat) -- works even though they're both from different libraries
The documentation for the math library can be found at http://www.lua.org/manual/5.3/ or from the Hammerspoon console via the help command: help.lua.math. This includes the following functions and variables:
help.lua.math.abshelp.lua.math.acoshelp.lua.math.asinhelp.lua.math.atanhelp.lua.math.ceilhelp.lua.math.coshelp.lua.math.deghelp.lua.math.exphelp.lua.math.floorhelp.lua.math.fmodhelp.lua.math.hugehelp.lua.math.loghelp.lua.math.maxhelp.lua.math.maxintegerhelp.lua.math.minhelp.lua.math.minintegerhelp.lua.math.modfhelp.lua.math.pihelp.lua.math.radhelp.lua.math.randomhelp.lua.math.randomseedhelp.lua.math.sinhelp.lua.math.sqrthelp.lua.math.tanhelp.lua.math.tointegerhelp.lua.math.typehelp.lua.math.ultAdditional functions and values that are specific to Hammerspoon which provide expanded math support are documented here.
| Signature | hs.math.minFloat |
|---|---|
| Type | Constant |
| Description | Smallest positive floating point number representable in Hammerspoon |
| Notes |
|
| Source | extensions/math/math.lua line 96 |
| Signature | hs.math.isFinite(value) -> boolean |
|---|---|
| Type | Function |
| Description | Returns whether or not the value is a finite number |
| Parameters |
|
| Returns |
|
| Notes |
|
| Source | extensions/math/math.lua line 78 |
| Signature | hs.math.isInfinite(value) -> 1, -1, false |
|---|---|
| Type | Function |
| Description | Returns whether or not the value is the mathematical equivalent of either positive or negative "Infinity" |
| Parameters |
|
| Returns |
|
| Notes |
|
| Source | extensions/math/math.lua line 61 |
| Signature | hs.math.isNaN(value) -> boolean |
|---|---|
| Type | Function |
| Description | Returns whether or not the value is the mathematical equivalent of "Not-A-Number" |
| Parameters |
|
| Returns |
|
| Notes |
|
| Source | extensions/math/math.lua line 44 |
| Signature | hs.math.randomFloat() -> number |
|---|---|
| Type | Function |
| Description | Returns a random floating point number between 0 and 1 |
| Parameters |
|
| Returns |
|
| Source | extensions/math/libmath.m line 6 |
| Signature | hs.math.randomFromRange(start, end) -> integer |
|---|---|
| Type | Function |
| Description | Returns a random integer between the start and end parameters |
| Parameters |
|
| Returns |
|
| Source | extensions/math/libmath.m line 26 |