Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.1.0 - Français

Change language to:
English - 日本語 - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Aide de Scilab >> Fonctions Elémentaires > Exponentielle > log2

log2

logarithme en base 2

Séquence d'appel

y = log2(x)
[m, e] = log2(u)

Paramètres

x, y

tableaux de nombres décimaux ou complexes, tels que 2.^y = x.

u, m, e

Tableaux de nombres décimaux tels que u = m .* 2.^e, avec sign(m)=sign(u) et 0.5 ≤ abs(m) < 1.

Description

log2(x) calcule le logarithme en base 2 élément par élément : y(i,j)=log2(x(i,j)).

log2(-%inf) == %inf + log2(-1)

[m, e] = log2(u) calcule élément par élément la mantisse m et l'exposant e de tous les éléments de u. Ainsi, pour tout indice k nous avons u(k) = m(k) .* 2.^e(k) avec 0.5 ≤ |m(k)| < 1.

  • [m, e] = log2([0 %nan -%inf %inf]) donne m=[0 NaN -Inf Inf] et e=[0 0 0 0].
  • Cette syntaxe correspond à la fonction nommée frexp() en langage C ANSI.

Exemples

Logarithme en base 2:

L = log2([-1, 1, 2, %i, -%i])
clean(2.^L)
L = log2([0 %nan %inf])
2 .^ L
L = log2([0 %nan %inf -%inf]) // -%inf<0 rend le résultat complexe
2 .^ L                        // -Inf n'est pas retrouvé
--> L = log2([-1, 1, 2, %i, -%i])
 L  =
   4.5323601i   0.   1.   2.2661801i  -2.2661801i

--> clean(2.^L)
 ans  =
  -1.   1.   2.   i   -i

--> L = log2([0 %nan %inf])
 L  =
  -Inf   Nan   Inf

--> 2 .^ L
 ans  =
   0.   Nan   Inf

--> L = log2([0 %nan %inf -%inf]) // -%inf<0 rend le résultat complexe
 L  =
  -Inf   Nan + Nani   Inf   Inf + 4.5323601i

--> 2 .^ L                        // -Inf n'est pas retrouvé
 ans  =
   0.   Nan + Nani   Inf   Nan + Nani

Décomposition en mantisses et exposants en base 2 :

[m, e] = log2([-3, -1.5, -1, 0, 4, 1e20])
m .* 2.^e
--> [m, e] = log2([-3, -1.5, -1, 0, 4, 1e20])
 e  =
   2.     1.     1.    0.   3.   67.
 m  =
  -0.75  -0.75  -0.5   0.   0.5   0.6776264

--> m .* 2.^e
 ans  =
  -3.  -1.5  -1.   0.   4.   1.000D+20

np = number_properties;
x = [%eps np("tiniest") np("tiny") np("huge")]
[m, e] = log2(x)
--> x = [%eps np("tiniest") np("tiny") np("huge")]
 x  =
    2.220D-16    4.94D-324    2.22D-308    1.79D+308

--> [m, e] = log2(x)
 e  =
  - 51.  - 1073.  - 1021.    1024.
 m  =
    0.5    0.5    0.5    1.

[m, e] = log2([0 %nan -%inf %inf])
m .* 2.^e
-->[m, e] = log2([0 %nan -%inf %inf])
 e  =
    0.    0.    0.    0.
 m  =
    0.    Nan  - Inf    Inf

-->m .* 2.^e
 ans  =
    0.    Nan  - Inf    Inf

Voir aussi

  • log — logarithme naturel
  • log10 — logarithme en base 10
  • nextpow2 — next higher power of 2.
  • bitstring — A string giving the literal bit representation of a number
  • hat — élévation à la puissance
  • logm — logarithme matriciel d'une matrice carrée
Report an issue
<< log1p Exponentielle logm >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Feb 25 08:50:19 CET 2020