1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 22:42:08 +00:00

LibJS: Add Math.imul()

This commit is contained in:
Idan Horowitz 2021-06-05 01:43:10 +03:00 committed by Linus Groh
parent de10f0dc6c
commit 9d2e90d569
2 changed files with 13 additions and 0 deletions

View file

@ -51,6 +51,7 @@ void MathObject::initialize(GlobalObject& global_object)
define_native_function(vm.names.atan2, atan2, 2, attr);
define_native_function(vm.names.fround, fround, 1, attr);
define_native_function(vm.names.hypot, hypot, 2, attr);
define_native_function(vm.names.imul, imul, 2, attr);
define_native_function(vm.names.log, log, 1, attr);
define_native_function(vm.names.log2, log2, 1, attr);
define_native_function(vm.names.log10, log10, 1, attr);
@ -428,6 +429,17 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::hypot)
return Value(::sqrt(hypot.as_double()));
}
JS_DEFINE_NATIVE_FUNCTION(MathObject::imul)
{
auto a = vm.argument(0).to_u32(global_object);
if (vm.exception())
return {};
auto b = vm.argument(1).to_u32(global_object);
if (vm.exception())
return {};
return Value(static_cast<i32>(a * b));
}
JS_DEFINE_NATIVE_FUNCTION(MathObject::log)
{
auto number = vm.argument(0).to_number(global_object);