PBXB64 Science & Math
80+ Functions PBXB64 Addition
A complete scientific computing toolkit built into the compiler. No external libraries needed. Covers trigonometry, linear algebra, statistics, random numbers, hyperbolic functions, DEC128/RATIONAL conversion, and more.
Function Reference
SIN / COS / TANTrigonometric (radians)ATN / ATN2Arc-tangent (1-arg, 2-arg)SINH / COSH / TANHHyperbolic functionsASINH / ACOSH / ATANHInverse hyperbolicEXP / LOG / LOG10Exponential, natural log, base-10SQR / CBRTSquare root, cube rootHYPOTHypotenuse: sqrt(x² + y²)ABS / FIX / INTAbsolute, truncate, floorCEIL / FLOOR / ROUNDRounding functionsSIGN / SGNSign of numberMIN / MAXMinimum / maximumRND / RNDGAUSSUniform & Gaussian randomRANDOMIZE / RNGSEEDSeed random generatorRNGDEFAULTReset to default seedDET / DET2Matrix determinantDOT / NORMVector dot product, Euclidean normPIConstant 3.14159...DEG / RADDegrees ↔ radiansDEC128 / RATIONALConversion functionsISCLOSENear-equality testLinear Algebra: DET, DOT, NORM
Matrix & vector operations
FUNCTION PBMAIN() AS LONG
LOCAL m11 AS DOUBLE, m12 AS DOUBLE
LOCAL m21 AS DOUBLE, m22 AS DOUBLE
LOCAL det AS DOUBLE
m11 = 4.0 : m12 = 7.0
m21 = 2.0 : m22 = 6.0
det = DET2(m11, m12, m21, m22) ' 4*6 - 7*2 = 10
PRINT "Determinant: "; det ' 10.0
LOCAL a1 AS DOUBLE, a2 AS DOUBLE
LOCAL b1 AS DOUBLE, b2 AS DOUBLE
LOCAL dot AS DOUBLE
a1 = 1.0 : a2 = 2.0
b1 = 3.0 : b2 = 4.0
dot = DOT(a1, a2, b1, b2) ' 1*3 + 2*4 = 11
PRINT "Dot product: "; dot ' 11.0
FUNCTION = 0
END FUNCTIONDET2 computes a 2×2 determinant. DOT computes the dot product of two vectors. NORM returns the Euclidean length.
Random Numbers: RND, RNDGAUSS, RNGSEED
Seeded random generation
FUNCTION PBMAIN() AS LONG
LOCAL r AS DOUBLE
LOCAL g AS DOUBLE
RNGSEED 12345 ' Reproducible seed
r = RND() ' Uniform [0, 1)
PRINT "Uniform: "; r
g = RNDGAUSS() ' Gaussian (mean=0, std=1)
PRINT "Gaussian: "; g
RNGDEFAULT ' Reset to default seed
FUNCTION = 0
END FUNCTIONRNGSEED sets a deterministic seed for reproducible results. RNDGAUSS uses the Box-Muller transform for Gaussian-distributed random numbers.
Hyperbolic Functions
SINH, COSH, TANH, ASINH, ACOSH, ATANH
FUNCTION PBMAIN() AS LONG
LOCAL x AS DOUBLE
LOCAL s AS DOUBLE
LOCAL c AS DOUBLE
x = 1.0
s = SINH(x) ' 1.1752...
c = COSH(x) ' 1.5430...
PRINT "sinh(1) = "; s
PRINT "cosh(1) = "; c
PRINT "tanh(1) = "; TANH(x)
' Inverse hyperbolic
PRINT "asinh(1.1752) = "; ASINH(s)
FUNCTION = 0
END FUNCTIONFull hyperbolic suite including inverse variants. All implemented natively in the runtime.
ATN2 - Two-Argument Arc-Tangent
ATN2 - correct quadrant
FUNCTION PBMAIN() AS LONG
LOCAL angle AS DOUBLE
angle = ATN2(1.0, 1.0) ' 45 degrees (PI/4)
PRINT "ATN2(1, 1) = "; angle
angle = ATN2(-1.0, -1.0) ' -135 degrees (-3PI/4)
PRINT "ATN2(-1, -1) = "; angle
angle = ATN2(0.0, -1.0) ' 180 degrees (PI)
PRINT "ATN2(0, -1) = "; angle
FUNCTION = 0
END FUNCTIONATN2(y, x) returns the angle in the correct quadrant, unlike ATN(y/x) which loses quadrant information.