mirror of
https://github.com/RGBCube/serenity
synced 2025-07-06 13:47:35 +00:00
LibJS: Add Math.imul()
This commit is contained in:
parent
de10f0dc6c
commit
9d2e90d569
2 changed files with 13 additions and 0 deletions
|
@ -51,6 +51,7 @@ void MathObject::initialize(GlobalObject& global_object)
|
||||||
define_native_function(vm.names.atan2, atan2, 2, attr);
|
define_native_function(vm.names.atan2, atan2, 2, attr);
|
||||||
define_native_function(vm.names.fround, fround, 1, attr);
|
define_native_function(vm.names.fround, fround, 1, attr);
|
||||||
define_native_function(vm.names.hypot, hypot, 2, 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.log, log, 1, attr);
|
||||||
define_native_function(vm.names.log2, log2, 1, attr);
|
define_native_function(vm.names.log2, log2, 1, attr);
|
||||||
define_native_function(vm.names.log10, log10, 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()));
|
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)
|
JS_DEFINE_NATIVE_FUNCTION(MathObject::log)
|
||||||
{
|
{
|
||||||
auto number = vm.argument(0).to_number(global_object);
|
auto number = vm.argument(0).to_number(global_object);
|
||||||
|
|
|
@ -47,6 +47,7 @@ private:
|
||||||
JS_DECLARE_NATIVE_FUNCTION(atan2);
|
JS_DECLARE_NATIVE_FUNCTION(atan2);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(fround);
|
JS_DECLARE_NATIVE_FUNCTION(fround);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(hypot);
|
JS_DECLARE_NATIVE_FUNCTION(hypot);
|
||||||
|
JS_DECLARE_NATIVE_FUNCTION(imul);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(log);
|
JS_DECLARE_NATIVE_FUNCTION(log);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(log2);
|
JS_DECLARE_NATIVE_FUNCTION(log2);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(log10);
|
JS_DECLARE_NATIVE_FUNCTION(log10);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue