Skip to content

Commit

Permalink
Add accuracy note for 2-arg log (#18360)
Browse files Browse the repository at this point in the history
* Add accuracy note for 2-arg log

Addresses #18298.

* update based on comments
  • Loading branch information
simonbyrne authored and stevengj committed Sep 7, 2016
1 parent 442af7b commit 5f74d16
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@ julia> log(4,8)
julia> log(4,2)
0.5
```
!!! note
If `b` is a power of 2 or 10, `log2` or `log10` should be used, as these will
typically be faster and more accurate. For example,
```jldoctest
julia> log(100,1000000)
2.9999999999999996
julia> log10(1000000)/2
3.0
```
"""
log(b::Number, x::Number) = log(promote(b,x)...)

Expand Down
12 changes: 12 additions & 0 deletions doc/stdlib/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,18 @@ Mathematical Functions
julia> log(4,2)
0.5

.. note::
If ``b`` is a power of 2 or 10, ``log2`` or ``log10`` should be used, as these will typically be faster and more accurate. For example,

.. doctest::

julia> log(100,1000000)
2.9999999999999996

julia> log10(1000000)/2
3.0


.. function:: log2(x)

.. Docstring generated from Julia source
Expand Down

0 comments on commit 5f74d16

Please sign in to comment.