From b76e84f0ab474e7e018d25e3fc1420912addd528 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Mon, 9 Mar 2015 16:53:41 -0400 Subject: [PATCH] lib: intro `Float::log_base` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/standard/math.nit | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/standard/math.nit b/lib/standard/math.nit index eec0cf6..2b55dca 100644 --- a/lib/standard/math.nit +++ b/lib/standard/math.nit @@ -167,12 +167,18 @@ redef class Float # #assert 0.0.pow(9.0) == 0.0 fun pow(e: Float): Float is extern "kernel_Float_Float_pow_1" - # Returns the logarithm of `self`. + # Natural logarithm of `self`. # # assert 0.0.log.is_inf == -1 # #assert 1.0.log == 0.0 fun log: Float is extern "kernel_Float_Float_log_0" + # Logarithm of `self` to base `base`. + # + # assert 100.0.log_base(10.0) == 2.0 + # assert 256.0.log_base(2.0) == 8.0 + fun log_base(base: Float): Float do return log/base.log + # Returns *e* raised to `self`. fun exp: Float is extern "kernel_Float_Float_exp_0" -- 1.7.9.5