aboutsummaryrefslogtreecommitdiffstats
path: root/lang/rust/files/log2.patch
blob: ed0b307f6a664213297485058cea418b5c19fa2b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
--- src/libcore/cmath.rs.orig   2012-10-16 21:22:12.704922039 +0800
+++ src/libcore/cmath.rs    2012-10-16 21:23:23.023337237 +0800
@@ -56,7 +56,6 @@
     // renamed: to be consitent with log as ln
     #[link_name="log1p"] pure fn ln1p(n: c_double) -> c_double;
     pure fn log10(n: c_double) -> c_double;
-    pure fn log2(n: c_double) -> c_double;
     #[link_name="ilogb"] pure fn ilog_radix(n: c_double) -> c_int;
     pure fn modf(n: c_double, iptr: &mut c_double) -> c_double;
     pure fn pow(n: c_double, e: c_double) -> c_double;
@@ -131,7 +130,6 @@
     #[link_name="logf"] pure fn ln(n: c_float) -> c_float;
     #[link_name="logbf"] pure fn log_radix(n: c_float) -> c_float;
     #[link_name="log1pf"] pure fn ln1p(n: c_float) -> c_float;
-    #[link_name="log2f"] pure fn log2(n: c_float) -> c_float;
     #[link_name="log10f"] pure fn log10(n: c_float) -> c_float;
     #[link_name="ilogbf"] pure fn ilog_radix(n: c_float) -> c_int;
     #[link_name="modff"] pure fn modf(n: c_float,
--- src/libcore/f32.rs.orig 2012-10-16 21:22:27.909922315 +0800
+++ src/libcore/f32.rs  2012-10-16 21:24:32.932336957 +0800
@@ -135,7 +135,11 @@
 }
 
 pub pure fn logarithm(n: f32, b: f32) -> f32 {
-    return log2(n) / log2(b);
+    return ln(n) / ln(b);
+}
+
+pub pure fn log2(n: f32) -> f32 {
+    return ln(n) / consts::ln_2;
 }
 
 impl f32: num::Num {
--- src/libcore/f64.rs.orig 2012-10-16 21:22:34.895921647 +0800
+++ src/libcore/f64.rs  2012-10-16 21:25:30.466586496 +0800
@@ -154,7 +154,11 @@
 }
 
 pub pure fn logarithm(n: f64, b: f64) -> f64 {
-    return log2(n) / log2(b);
+    return ln(n) / ln(b);
+}
+
+pub pure fn log2(n: f64) -> f64 {
+    return ln(n) / consts::ln_2;
 }
 
 impl f64: num::Num {