mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
More accurate logarithm for base 2 and 10
This commit is contained in:
parent
8debba439c
commit
cb3c263c4a
@ -366,7 +366,13 @@ pub fn log(
|
|||||||
#[default(10.0)]
|
#[default(10.0)]
|
||||||
base: f64,
|
base: f64,
|
||||||
) -> Value {
|
) -> Value {
|
||||||
Value::Float(value.log(base))
|
Value::Float(if base == 2.0 {
|
||||||
|
value.log2()
|
||||||
|
} else if base == 10.0 {
|
||||||
|
value.log10()
|
||||||
|
} else {
|
||||||
|
value.log(base)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Round a number down to the nearest integer.
|
/// Round a number down to the nearest integer.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user