XU XUv0.8.8
中文

API

#math

import: #math

counts: 49 fns, 0 methods, 2 types, 0 consts, 0 ifaces

Common real functions plus Pi/E. pow is integer exponent; pow_f64 is floating power.

fma

XuAPI
pub fn fma(x f64, y f64, z f64) f64

Purpose

fma; returns f64.

Parameters

x f64
value (f64)
y f64
value (f64)
z f64
z (f64)

Returns

f64 — a value of this type

abs

XuAPI
pub fn abs(x f64) f64

Purpose

Absolute value.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

min

XuAPI
pub fn min(a f64, b f64) f64

Purpose

Minimum.

Parameters

a f64
left operand (f64)
b f64
right operand (f64)

Returns

f64 — a value of this type

max

XuAPI
pub fn max(a f64, b f64) f64

Purpose

Maximum.

Parameters

a f64
left operand (f64)
b f64
right operand (f64)

Returns

f64 — a value of this type

floor

XuAPI
pub fn floor(x f64) f64

Purpose

Floor.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

ceil

XuAPI
pub fn ceil(x f64) f64

Purpose

Ceiling.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

sqrt

XuAPI
pub fn sqrt(x f64) f64

Purpose

Square root.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

pow

XuAPI
pub fn pow(x f64, n int) f64

Purpose

Power.

Parameters

x f64
value (f64)
n int
count, length, or limit (int)

Returns

f64 — a value of this type

exp

XuAPI
pub fn exp(x f64) f64

Purpose

e to the power.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

log

XuAPI
pub fn log(x f64) f64

Purpose

Natural logarithm.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

hypot

XuAPI
pub fn hypot(a f64, b f64) f64

Purpose

hypot; returns f64.

Parameters

a f64
left operand (f64)
b f64
right operand (f64)

Returns

f64 — a value of this type

pi

XuAPI
pub fn pi() f64

Purpose

pi; returns f64.

Parameters

none

Returns

f64 — a value of this type

e

XuAPI
pub fn e() f64

Purpose

e; returns f64.

Parameters

none

Returns

f64 — a value of this type

ln2

XuAPI
pub fn ln2() f64

Purpose

ln2; returns f64.

Parameters

none

Returns

f64 — a value of this type

is_nan

XuAPI
pub fn is_nan(x f64) bool

Purpose

Whether the value is NaN.

Parameters

x f64
value (f64)

Returns

bool — true or false

struct Frexp

XuAPI
pub struct Frexp {
    pub frac f64
    pub exp int
}

Purpose

Public struct `Frexp`.

Parameters

frac f64
field (f64)
exp int
field (int)

ldexp

XuAPI
pub fn ldexp(frac f64, exp int) f64

Purpose

ldexp; returns f64.

Parameters

frac f64
frac (f64)
exp int
exp (int)

Returns

f64 — a value of this type

frexp

XuAPI
pub fn frexp(x f64) Frexp

Purpose

frexp; returns Frexp.

Parameters

x f64
value (f64)

Returns

Frexp — a value of this type

dim

XuAPI
pub fn dim(x f64, y f64) f64

Purpose

dim; returns f64.

Parameters

x f64
value (f64)
y f64
value (f64)

Returns

f64 — a value of this type

remainder

XuAPI
pub fn remainder(x f64, y f64) f64

Purpose

remainder; returns f64.

Parameters

x f64
value (f64)
y f64
value (f64)

Returns

f64 — a value of this type

is_inf

XuAPI
pub fn is_inf(x f64) bool

Purpose

Whether the value is infinity.

Parameters

x f64
value (f64)

Returns

bool — true or false

copysign

XuAPI
pub fn copysign(mag f64, sign f64) f64

Purpose

copysign; returns f64.

Parameters

mag f64
mag (f64)
sign f64
sign (f64)

Returns

f64 — a value of this type

trunc

XuAPI
pub fn trunc(x f64) f64

Purpose

trunc; returns f64.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

mod

XuAPI
pub fn mod(x f64, y f64) f64

Purpose

Modulo.

Parameters

x f64
value (f64)
y f64
value (f64)

Returns

f64 — a value of this type

round

XuAPI
pub fn round(x f64) f64

Purpose

round; returns f64.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

round_to_even

XuAPI
pub fn round_to_even(x f64) f64

Purpose

Round to even.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

sin

XuAPI
pub fn sin(x f64) f64

Purpose

Sine.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

cos

XuAPI
pub fn cos(x f64) f64

Purpose

Cosine.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

tan

XuAPI
pub fn tan(x f64) f64

Purpose

Tangent.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

atan

XuAPI
pub fn atan(x f64) f64

Purpose

atan; returns f64.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

atan2

XuAPI
pub fn atan2(y f64, x f64) f64

Purpose

atan2; returns f64.

Parameters

y f64
value (f64)
x f64
value (f64)

Returns

f64 — a value of this type

nan

XuAPI
pub fn nan() f64

Purpose

nan; returns f64.

Parameters

none

Returns

f64 — a value of this type

inf

XuAPI
pub fn inf(sign int) f64

Purpose

inf; returns f64.

Parameters

sign int
sign (int)

Returns

f64 — a value of this type

signbit

XuAPI
pub fn signbit(x f64) bool

Purpose

signbit; returns bool.

Parameters

x f64
value (f64)

Returns

bool — true or false

pow_f64

XuAPI
pub fn pow_f64(x f64, y f64) f64

Purpose

pow_f64 is math.Pow. The existing pow(x, n int) stays because Xu has no overloads (same split as cmp.less_int / less_f64).

Parameters

x f64
value (f64)
y f64
value (f64)

Returns

f64 — a value of this type

log10

XuAPI
pub fn log10(x f64) f64

Purpose

log10; returns f64.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

log2

XuAPI
pub fn log2(x f64) f64

Purpose

log2; returns f64.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

exp2

XuAPI
pub fn exp2(x f64) f64

Purpose

exp2; returns f64.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

cbrt

XuAPI
pub fn cbrt(x f64) f64

Purpose

cbrt; returns f64.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

asin

XuAPI
pub fn asin(x f64) f64

Purpose

asin; returns f64.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

acos

XuAPI
pub fn acos(x f64) f64

Purpose

acos; returns f64.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

struct ModfResult

XuAPI
pub struct ModfResult {
    pub intg f64
    pub frac f64
}

Purpose

Public struct `ModfResult`.

Parameters

intg f64
field (f64)
frac f64
field (f64)

sinh

XuAPI
pub fn sinh(x f64) f64

Purpose

sinh; returns f64.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

cosh

XuAPI
pub fn cosh(x f64) f64

Purpose

cosh; returns f64.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

tanh

XuAPI
pub fn tanh(x f64) f64

Purpose

tanh; returns f64.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

asinh

XuAPI
pub fn asinh(x f64) f64

Purpose

Inverse hyperbolic functions ( Asinh/Acosh/Atanh). Combined from log/sqrt like sinh/cosh/tanh; large |x| uses log(2*|x|) so x*x does not overflow to Inf.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

acosh

XuAPI
pub fn acosh(x f64) f64

Purpose

acosh; returns f64.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

atanh

XuAPI
pub fn atanh(x f64) f64

Purpose

atanh; returns f64.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

modf

XuAPI
pub fn modf(x f64) ModfResult

Purpose

modf; returns ModfResult.

Parameters

x f64
value (f64)

Returns

ModfResult — a value of this type

log1p

XuAPI
pub fn log1p(x f64) f64

Purpose

log1p is Log1p: ln(1+x). Small |x| returns x so 1+x does not round away the addend.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type

expm1

XuAPI
pub fn expm1(x f64) f64

Purpose

expm1 is Expm1: e^x - 1. Small |x| returns x so exp(x)-1 does not collapse to 0.

Parameters

x f64
value (f64)

Returns

f64 — a value of this type