mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-14 07:21:30 +00:00
Add Math.signbit (#333)
This commit is contained in:
@ -992,6 +992,13 @@ export namespace NativeMath {
|
||||
}
|
||||
}
|
||||
|
||||
@inline
|
||||
export function signbit(x: f64): bool {
|
||||
// In ECMAScript all NaN values are indistinguishable from each other
|
||||
// so we need handle NaN and negative NaN in similar way
|
||||
return <bool>(<i32>(reinterpret<u64>(x) >>> 63) & (x == x));
|
||||
}
|
||||
|
||||
export function sin(x: f64): f64 { // TODO
|
||||
unreachable();
|
||||
return 0;
|
||||
@ -2046,6 +2053,11 @@ export namespace NativeMathf {
|
||||
}
|
||||
}
|
||||
|
||||
@inline
|
||||
export function signbit(x: f32): bool {
|
||||
return <bool>((reinterpret<u32>(x) >>> 31) & (x == x));
|
||||
}
|
||||
|
||||
export function sin(x: f32): f32 { // TODO
|
||||
unreachable();
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user