Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: MIN_NORMAL_VALUE and add POSITIVE_INFINITY/NEGATIVE_INFINITY #1443

Merged
merged 10 commits into from
Aug 20, 2020
18 changes: 17 additions & 1 deletion std/assembly/builtins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export declare function assert<T>(isTrueish: T, message?: string): T;
@unsafe @builtin
export declare function unchecked<T>(expr: T): T;

// @ts-ignore: decorator
// @ts-ignore: decorator
@unsafe @builtin
export declare function call_indirect<T>(index: u32, ...args: auto[]): T;

Expand Down Expand Up @@ -846,6 +846,14 @@ export namespace f32 {
@lazy
export const MAX_SAFE_INTEGER: f32 = 16777215;

// @ts-ignore: decorator
@lazy
export const POSITIVE_INFINITY: f32 = Infinity;

// @ts-ignore: decorator
@lazy
export const NEGATIVE_INFINITY: f32 = -Infinity;

// @ts-ignore: decorator
@builtin
export declare function abs(value: f32): f32;
Expand Down Expand Up @@ -925,6 +933,14 @@ export namespace f64 {
@lazy
export const MAX_SAFE_INTEGER: f64 = 9007199254740991;

// @ts-ignore: decorator
@lazy
export const POSITIVE_INFINITY: f64 = Infinity;

// @ts-ignore: decorator
@lazy
export const NEGATIVE_INFINITY: f64 = -Infinity;

// @ts-ignore: decorator
@builtin
export declare function abs(value: f64): f64;
Expand Down
12 changes: 10 additions & 2 deletions std/assembly/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,15 @@ declare namespace f32 {
/** Largest representable value. */
export const MAX_VALUE: f32;
/** Smallest normalized positive value. */
export const MIN_POSITIVE_VALUE: f32;
export const MIN_NORMAL_VALUE: f32;
/** Smallest safely representable integer value. */
export const MIN_SAFE_INTEGER: f32;
/** Largest safely representable integer value. */
export const MAX_SAFE_INTEGER: f32;
/** Positive infinity value. */
export const POSITIVE_INFINITY: f32;
/** Negative infinity value. */
export const NEGATIVE_INFINITY: f32;
/** Difference between 1 and the smallest representable value greater than 1. */
export const EPSILON: f32;
/** Loads a 32-bit float from memory. */
Expand All @@ -526,11 +530,15 @@ declare namespace f64 {
/** Largest representable value. */
export const MAX_VALUE: f64;
/** Smallest normalized positive value. */
export const MIN_POSITIVE_VALUE: f64;
export const MIN_NORMAL_VALUE: f64;
/** Smallest safely representable integer value. */
export const MIN_SAFE_INTEGER: f64;
/** Largest safely representable integer value. */
export const MAX_SAFE_INTEGER: f64;
/** Positive infinity value. */
export const POSITIVE_INFINITY: f64;
/** Negative infinity value. */
export const NEGATIVE_INFINITY: f64;
/** Difference between 1 and the smallest representable value greater than 1. */
export const EPSILON: f64;
/** Loads a 64-bit float from memory. */
Expand Down
12 changes: 10 additions & 2 deletions std/portable/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,15 @@ declare namespace f32 {
/** Largest representable value. */
export const MAX_VALUE: f32;
/** Smallest normalized positive value. */
export const MIN_POSITIVE_VALUE: f32;
export const MIN_NORMAL_VALUE: f32;
/** Smallest safely representable integer value. */
export const MIN_SAFE_INTEGER: f32;
/** Largest safely representable integer value. */
export const MAX_SAFE_INTEGER: f32;
/** Positive infinity value. */
export const POSITIVE_INFINITY: f32;
/** Negative infinity value. */
export const NEGATIVE_INFINITY: f32;
MaxGraey marked this conversation as resolved.
Show resolved Hide resolved
/** Difference between 1 and the smallest representable value greater than 1. */
export const EPSILON: f32;
/** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */
Expand All @@ -258,11 +262,15 @@ declare namespace f64 {
/** Largest representable value. */
export const MAX_VALUE: f64;
/** Smallest normalized positive value. */
export const MIN_POSITIVE_VALUE: f64;
export const MIN_NORMAL_VALUE: f64;
/** Smallest safely representable integer value. */
export const MIN_SAFE_INTEGER: f64;
/** Largest safely representable integer value. */
export const MAX_SAFE_INTEGER: f64;
/** Positive infinity value. */
export const POSITIVE_INFINITY: f64;
/** Negative infinity value. */
export const NEGATIVE_INFINITY: f64;
/** Difference between 1 and the smallest representable value greater than 1. */
export const EPSILON: f64;
/** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */
Expand Down
8 changes: 6 additions & 2 deletions std/portable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ Object.defineProperties(
"MAX_VALUE": { value: Math.fround(3.4028235e+38), writable: false },
"MIN_NORMAL_VALUE": { value: Math.fround(1.17549435e-38), writable: false },
"MIN_SAFE_INTEGER": { value: -16777215, writable: false },
"MAX_SAFE_INTEGER": { value: 16777215, writable: false }
"MAX_SAFE_INTEGER": { value: 16777215, writable: false },
"POSITIVE_INFINITY": { value: Math.fround(Infinity), writable: false },
"NEGATIVE_INFINITY": { value: Math.fround(-Infinity), writable: false }
MaxGraey marked this conversation as resolved.
Show resolved Hide resolved
}
);

Expand All @@ -92,7 +94,9 @@ Object.defineProperties(
"MAX_VALUE": { value: 1.7976931348623157e+308, writable: false },
"MIN_NORMAL_VALUE": { value: 2.2250738585072014e-308 , writable: false },
"MIN_SAFE_INTEGER": { value: -9007199254740991, writable: false },
"MAX_SAFE_INTEGER": { value: 9007199254740991, writable: false }
"MAX_SAFE_INTEGER": { value: 9007199254740991, writable: false },
"POSITIVE_INFINITY": { value: Infinity, writable: false },
"NEGATIVE_INFINITY": { value: -Infinity, writable: false }
}
);

Expand Down