Module
Module documentation.
modulemath
@briefMathematical functions
@detailsProvides portable approximations for common Float operations.
@see
- index.html
Classes
Classes and inheritance.
Functions
Free functions and class methods.
functionmath::to_float
Signature
func to_float(x: Int) -> Floatfunc to_float(x: Int) -> Float {
return strconv.parse_float(strconv.itoa(x));
}@briefConverts to the target representation with `to_float`.
@detailsExecutes the `to_float` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- xInput value.
@returnReturns the operation result as `Float`.
functionmath::pi
Signature
func pi() -> Floatfunc pi() -> Float {
return 3.141592653589793;
}@briefProvides the system library operation `pi`.
@detailsExecutes the `pi` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@returnReturns the operation result as `Float`.
functionmath::e
Signature
func e() -> Floatfunc e() -> Float {
return 2.718281828459045;
}@briefProvides the system library operation `e`.
@detailsExecutes the `e` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@returnReturns the operation result as `Float`.
functionmath::abs
Signature
func abs(x: Float) -> Floatfunc abs(x: Float) -> Float {
if x < 0.0 {
return 0.0 - x;@briefProvides the system library operation `abs`.
@detailsExecutes the `abs` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- xInput value.
@returnReturns the operation result as `Float`.
functionmath::min
Signature
func min(x: Float, y: Float) -> Floatfunc min(x: Float, y: Float) -> Float {
if x < y {
return x;@briefProvides the system library operation `min`.
@detailsExecutes the `min` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- xInput value.
- ySecond numeric operand or coordinate value used by the operation.
@returnReturns the operation result as `Float`.
functionmath::max
Signature
func max(x: Float, y: Float) -> Floatfunc max(x: Float, y: Float) -> Float {
if x > y {
return x;@briefProvides the system library operation `max`.
@detailsExecutes the `max` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- xInput value.
- ySecond numeric operand or coordinate value used by the operation.
@returnReturns the operation result as `Float`.
functionmath::clamp
Signature
func clamp(x: Float, lo: Float, hi: Float) -> Floatfunc clamp(x: Float, lo: Float, hi: Float) -> Float {
if x < lo {
return lo;@briefProvides the system library operation `clamp`.
@detailsExecutes the `clamp` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- xInput value.
- loLower pointer, index, or numeric boundary used by the operation.
- hiUpper pointer, index, or numeric boundary used by the operation.
@returnReturns the operation result as `Float`.
functionmath::sqrt
Signature
func sqrt(x: Float) -> Floatfunc sqrt(x: Float) -> Float {
if x <= 0.0 {
return 0.0;@briefProvides the system library operation `sqrt`.
@detailsExecutes the `sqrt` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- xInput value.
@returnReturns the operation result as `Float`.
functionmath::exp
Signature
func exp(x: Float) -> Floatfunc exp(x: Float) -> Float {
if x < -40.0 {
return 0.0;@briefProvides the system library operation `exp`.
@detailsExecutes the `exp` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- xInput value.
@returnReturns the operation result as `Float`.
functionmath::log
Signature
func log(x: Float) -> Floatfunc log(x: Float) -> Float {
if x <= 0.0 {
return -1000000000000.0;@briefProvides the system library operation `log`.
@detailsExecutes the `log` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- xInput value.
@returnReturns the operation result as `Float`.
functionmath::ln
Signature
func ln(x: Float) -> Floatfunc ln(x: Float) -> Float {
return log(x);
}@briefProvides the system library operation `ln`.
@detailsExecutes the `ln` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- xInput value.
@returnReturns the operation result as `Float`.
functionmath::log10
Signature
func log10(x: Float) -> Floatfunc log10(x: Float) -> Float {
return log(x) / log(10.0);
}@briefProvides the system library operation `log10`.
@detailsExecutes the `log10` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- xInput value.
@returnReturns the operation result as `Float`.
functionmath::pow
Signature
func pow(x: Float, y: Float) -> Floatfunc pow(x: Float, y: Float) -> Float {
if x <= 0.0 {
return 0.0;@briefProvides the system library operation `pow`.
@detailsExecutes the `pow` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- xInput value.
- ySecond numeric operand or coordinate value used by the operation.
@returnReturns the operation result as `Float`.
functionmath::sigmoid
Signature
func sigmoid(x: Float) -> Floatfunc sigmoid(x: Float) -> Float {
return 1.0 / (1.0 + exp(0.0 - x));
}@briefProvides the system library operation `sigmoid`.
@detailsExecutes the `sigmoid` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- xInput value.
@returnReturns the operation result as `Float`.
functionmath::relu
Signature
func relu(x: Float) -> Floatfunc relu(x: Float) -> Float {
if x > 0.0 {
return x;@briefProvides the system library operation `relu`.
@detailsExecutes the `relu` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
- xInput value.
@returnReturns the operation result as `Float`.
Variables
Class fields (var).