From cb9e359a51c3249d8f5157db69d43fd413ddeda6 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 14:45:12 +0100 Subject: unslug ca: move --- .../reference/global_objects/math/log2/index.html | 127 +++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 files/ca/web/javascript/reference/global_objects/math/log2/index.html (limited to 'files/ca/web/javascript/reference/global_objects/math/log2/index.html') diff --git a/files/ca/web/javascript/reference/global_objects/math/log2/index.html b/files/ca/web/javascript/reference/global_objects/math/log2/index.html new file mode 100644 index 0000000000..0806bd75ff --- /dev/null +++ b/files/ca/web/javascript/reference/global_objects/math/log2/index.html @@ -0,0 +1,127 @@ +--- +title: Math.log2() +slug: Web/JavaScript/Referencia/Objectes_globals/Math/log2 +translation_of: Web/JavaScript/Reference/Global_Objects/Math/log2 +--- +
{{JSRef}}
+ +

La funció Math.log2() retorna el logaritme en base 2 d'un nombre, és a dir

+ +

x>0,Math.log2(x)=log2(x)=la únicaytal que2y=x\forall x > 0, \mathtt{\operatorname{Math.log2}(x)} = \log_2(x) = \text{the unique} \; y \; \text{such that} \; 2^y = x

+ +

Sintaxi

+ +
Math.log2(x)
+ +

Paràmetres

+ +
+
x
+
Un nombre.
+
+ +

Descripció

+ +

Si el valor de x és menor que 0, el valor retornat sempre serà {{jsxref("NaN")}}.

+ +

Com que log2() és un mètode estàtic de Math, sempre s'utilitza com Math.log2() en comptes de com un mètode d'un objecte Math creat (Math no és un constructor).

+ +

Exemples

+ +

Utilitzar Math.log2()

+ +
Math.log2(3);    // 1.584962500721156
+Math.log2(2);    // 1
+Math.log2(1);    // 0
+Math.log2(0);    // -Infinit
+Math.log2(-2);   // NaN
+Math.log2(1024); // 10
+
+ +

Polyfill

+ +

Aquest Polyfill emula la funció Math.log2. Cal destacar que retorna valors imprecisos per a algunes entrades (com ara 1 << 29), embolcalleu-la amb {{jsxref("Math.round()")}} si esteu treballant amb màscares de bits.

+ +
Math.log2 = Math.log2 || function(x) {
+  return Math.log(x) / Math.LN2;
+};
+
+ +

Especificacions

+ + + + + + + + + + + + + + +
EspecificacióEstatComentaris
{{SpecName('ES6', '#sec-math.log2', 'Math.log2')}}{{Spec2('ES6')}}Definició inicial.
+ +

Compatibilitat amb navegadors

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Suport bàsic{{CompatChrome("38")}}{{CompatGeckoDesktop("25")}}{{CompatNo}}{{CompatOpera("25")}}{{CompatSafari("7.1")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Suport bàsic{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("25")}}{{CompatNo}}{{CompatNo}}8
+
+ +

Vegeu també

+ + -- cgit v1.2.3-54-g00ecf