Move some numeric builtins to stdlib; Minor refactoring

This commit is contained in:
dcodeIO
2018-04-17 02:50:38 +02:00
parent 6d0b5d92c2
commit 4929fca363
26 changed files with 1987 additions and 1746 deletions

View File

@ -8,27 +8,25 @@ export declare function isString<T>(value?: T): bool;
export declare function isArray<T>(value?: T): bool;
export declare const NaN: f64; // | f32
export const NaN: f64 = 0 / 0;
export declare const Infinity: f64; // | f32
export const Infinity: f64 = 1 / 0;
export declare function isNaN<T>(value: T): bool;
// export function isNaN<T>(value: T): bool {
// return isFloat(value)
// ? sizeof<T>() == 32
// ? (reinterpret<u32>(value) & -1 >>> 1) > 0xFF << 23
// : (reinterpret<u64>(value) & -1 >>> 1) > 0x7FF << 52
// : false;
// }
export function isNaN<T>(value: T): bool {
return isFloat(value)
? sizeof<T>() == 32
? (reinterpret<u32>(value) & -1 >>> 1) > 0xFF << 23
: (reinterpret<u64>(value) & -1 >>> 1) > 0x7FF << 52
: false;
}
export declare function isFinite<T>(value: T): bool;
// export function isFinite<T>(value: T): bool {
// return isFloat(value)
// ? sizeof<T>() == 32
// ? (reinterpret<u32>(value) & -1 >>> 1) < 0xFF << 23
// : (reinterpret<u64>(value) & -1 >>> 1) < 0x7FF << 52
// : true;
// }
export function isFinite<T>(value: T): bool {
return isFloat(value)
? sizeof<T>() == 32
? (reinterpret<u32>(value) & -1 >>> 1) < 0xFF << 23
: (reinterpret<u64>(value) & -1 >>> 1) < 0x7FF << 52
: true;
}
export declare function clz<T>(value: T): T;