v / vlib / math / log.c.v
45 lines · 38 sloc · 843 bytes · fdfb3896e900dfc0b31cf9d8e0e43e1a2458e2cd
Raw
1module math
2
3fn C.log(x f64) f64
4fn C.log2(x f64) f64
5fn C.log10(x f64) f64
6fn C.log1p(x f64) f64
7fn C.logb(x f64) f64
8fn C.logf(x f32) f32
9
10// log returns the natural logarithm of x (float64)
11@[inline]
12pub fn log(x f64) f64 {
13 return C.log(x)
14}
15
16// log2 returns the binary logarithm of x (float64).
17// The special cases are the same as for log.
18@[inline]
19pub fn log2(x f64) f64 {
20 return C.log2(x)
21}
22
23// log10 returns the decimal logarithm of x (float64).
24// The special cases are the same as for log.
25@[inline]
26pub fn log10(x f64) f64 {
27 return C.log10(x)
28}
29
30// log1p returns log(1+x).
31@[inline]
32pub fn log1p(x f64) f64 {
33 return C.log1p(x)
34}
35
36// log_b returns the binary exponent of x.
37pub fn log_b(x f64) f64 {
38 return C.logb(x)
39}
40
41// log returns the natural logarithm of x (float32)
42@[inline]
43pub fn logf(x f32) f32 {
44 return C.logf(x)
45}
46