Skip to content

Commit e47a130

Browse files
committed
More math
1 parent 792202a commit e47a130

File tree

7 files changed

+2651
-508
lines changed

7 files changed

+2651
-508
lines changed

dist/asc.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/asc.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

std/assembly.d.ts

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,54 +354,106 @@ declare class Set<T> {
354354
}
355355

356356
interface IMath<T> {
357+
/** The base of natural logarithms, e, approximately 2.718. */
357358
readonly E: T;
359+
/** The natural logarithm of 2, approximately 0.693. */
358360
readonly LN2: T;
361+
/** The natural logarithm of 10, approximately 2.302. */
359362
readonly LN10: T;
363+
/** The base 2 logarithm of e, approximately 1.442. */
360364
readonly LOG2E: T;
365+
/** The base 10 logarithm of e, approximately 0.434. */
361366
readonly LOG10E: T;
367+
/** The ratio of the circumference of a circle to its diameter, approximately 3.14159. */
362368
readonly PI: T;
369+
/** The square root of 1/2, approximately 0.707. */
363370
readonly SQRT1_2: T;
371+
/** The square root of 2, approximately 1.414. */
364372
readonly SQRT2: T;
373+
/** Returns the absolute value of `x`. */
365374
abs(x: T): T;
375+
/** Returns the arccosine (in radians) of `x`. */
366376
acos(x: T): T;
377+
/** Returns the hyperbolic arc-cosine of `x`. */
367378
acosh(x: T): T;
379+
/** Returns the arcsine (in radians) of `x` */
368380
asin(x: T): T;
381+
/** Returns the hyperbolic arcsine of `x`. */
369382
asinh(x: T): T;
383+
/** Returns the arctangent (in radians) of `x`. */
370384
atan(x: T): T;
385+
/** Returns the arctangent of the quotient of its arguments. */
371386
atan2(y: T, x: T): T;
387+
/** Returns the hyperbolic arctangent of `x`. */
372388
atanh(x: T): T;
389+
/** Returns the cube root of `x`. */
373390
cbrt(x: T): T;
391+
/** Returns the smallest integer greater than or equal to `x`. */
374392
ceil(x: T): T;
393+
/** Returns the number of leading zero bits in the 32-bit binary representation of `x`. */
375394
clz32(x: T): i32;
395+
/** Returns the cosine (in radians) of `x`. */
376396
cos(x: T): T;
397+
/** Returns the hyperbolic cosine of `x`. */
377398
cosh(x: T): T;
399+
/** Returns e to the power of `x`. */
378400
exp(x: T): T;
401+
/** Returns e to the power of `x`, minus 1. */
379402
expm1(x: T): T;
403+
/** Returns the largest integer less than or equal to `x`. */
380404
floor(x: T): T;
405+
/** Returns the nearest 32-bit single precision float representation of `x`. */
381406
fround(x: T): f32;
407+
/** Returns the square root of the sum of squares of its arguments. */
382408
hypot(value1: T, value2: T): T; // TODO: rest
409+
/** Returns the result of the C-like 32-bit multiplication of `a` and `b`. */
383410
imul(a: T, b: T): i32;
411+
/** Returns the natural logarithm (base e) of `x`. */
384412
log(x: T): T;
413+
/** Returns the base 10 logarithm of `x`. */
385414
log10(x: T): T;
415+
/** Returns the natural logarithm (base e) of 1 + `x`. */
386416
log1p(x: T): T;
417+
/** Returns the base 2 logarithm of `x`. */
387418
log2(x: T): T;
419+
/** Returns the largest-valued number of its arguments. */
388420
max(value1: T, value2: T): T; // TODO: rest
421+
/** Returns the lowest-valued number of its arguments. */
389422
min(value1: T, value2: T): T; // TODO: rest
423+
/** Returns `base` to the power of `exponent`. */
390424
pow(base: T, exponent: T): T;
425+
/** Returns a pseudo-random number in the range from 0.0 inclusive up to but not including 1.0. */
391426
random(): T;
427+
/** Returns the value of `x` rounded to the nearest integer. */
392428
round(x: T): T;
429+
/** Returns the sign of `x`, indicating whether the number is positive, negative or zero. */
393430
sign(x: T): T;
431+
/** Returns the sine of `x`. */
394432
sin(x: T): T;
433+
/** Returns the hyperbolic sine of `x`. */
395434
sinh(x: T): T;
435+
/** Returns the square root of `x`. */
396436
sqrt(x: T): T;
437+
/** Returns the tangent of `x`. */
397438
tan(x: T): T;
439+
/** Returns the hyperbolic tangent of `x`. */
398440
tanh(x: T): T;
441+
/** Returns the integer part of `x` by removing any fractional digits. */
399442
trunc(x: T): T;
400443
}
401444

445+
interface ISeedRandom {
446+
/** Seeds the random number generator. */
447+
seedRandom(value: i64): void;
448+
}
449+
450+
/** Double precision math imported from JavaScript. */
402451
declare const JSMath: IMath<f64>;
403-
declare const NativeMath: IMath<f64>;
452+
/** Double precision math implemented natively. */
453+
declare const NativeMath: IMath<f64> & ISeedRandom;
454+
/** Single precision math implemented natively. */
404455
declare const NativeMathf: IMath<f32>;
456+
/** Alias of {@link NativeMath} or {@link JSMath} respectively. Defaults to `NativeMath`. */
405457
declare const Math: IMath<f64>;
406458

407459
// Internal decorators

0 commit comments

Comments
 (0)