This site is supported by donations to The OEIS Foundation.

Template:Log 2

From OeisWiki
Jump to: navigation, search

The {{log_2}} mathematical function template returns the binary logarithm of , where is a positive real number.

Usage

{{log_2|a positive real number}}

Valid input

A positive real number as argument.

Examples

Examples with valid input

Code Result
{{log_2|0.5}} -1
{{log_2|1}} 0
{{log_2|1.5}} 0.58496250072116
{{log_2|2}} 1
{{log_2|6}} 2.5849625007212
{{log_2|8}} 3
{{log_2|2^40}} 40

Examples with invalid input (returns an error message)

Code Result
{{log_2|i}} Log_2 error: Argument must be a positive real number
{{log_2|-1}} Log_2 error: Argument must be a positive real number
{{log_2|0}} Log_2 error: Argument must be a positive real number

Code


<noinclude>{{documentation}}</noinclude><includeonly>{{ifnum| {{{1|NaN}}}
| {{#ifexpr: ( {{{1}}} ) > 0
  | {{#expr: ln ( {{{1}}} ) / ln 2 }}
  | {{error| Log_2 error: Argument must be a positive real number }}
  }}
| {{error| Log_2 error: Argument must be a positive real number }}
}}</includeonly>

See also