Open
Description
Bug description
Mathf.log
functions don't return the correct value
Steps to reproduce
export function test_log(x: f32): f32 {
return Mathf.log(x) // x = 10 => -0.004908394999802113 // (incorrect)
}
export function test_log10(x: f32): f32 {
return Mathf.log10(x) // x = 10 => 1.0 // (correct)
}
export function test_log2(x: f32): f32 {
return Mathf.log2(x) // x = 10 => -0.005684611387550831 // (incorrect)
}
EXAMPLE FIX:
export function test_log_fixed(x: f32): f32 {
// x= 10 => 2.3025851249694824 (correct)
return Mathf.log10(x) * <f32>Math.LN10;
}
export function test_log2_fixed(x: f32): f32 {
// x = 10 => 3.321928024291992 (correct)
return (Mathf.log10(x) * <f32>Math.LN10) / <f32>Math.LN2
}
AssemblyScript version
0.28.2