mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Add calc constants
This commit is contained in:
parent
53844b5a87
commit
0ef1b02ee0
@ -30,6 +30,10 @@ pub fn calc() -> Module {
|
|||||||
scope.def_func::<EvenFunc>("even");
|
scope.def_func::<EvenFunc>("even");
|
||||||
scope.def_func::<OddFunc>("odd");
|
scope.def_func::<OddFunc>("odd");
|
||||||
scope.def_func::<ModFunc>("mod");
|
scope.def_func::<ModFunc>("mod");
|
||||||
|
scope.define("inf", Value::Float(f64::INFINITY));
|
||||||
|
scope.define("nan", Value::Float(f64::NAN));
|
||||||
|
scope.define("pi", Value::Float(std::f64::consts::PI));
|
||||||
|
scope.define("e", Value::Float(std::f64::consts::E));
|
||||||
Module::new("calc").with_scope(scope)
|
Module::new("calc").with_scope(scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
#test(float("31.4e-1"), 3.14)
|
#test(float("31.4e-1"), 3.14)
|
||||||
#test(type(float(10)), "float")
|
#test(type(float(10)), "float")
|
||||||
|
|
||||||
|
---
|
||||||
|
#test(calc.round(calc.e, digits: 2), 2.72)
|
||||||
|
#test(calc.round(calc.pi, digits: 2), 3.14)
|
||||||
|
|
||||||
---
|
---
|
||||||
// Error: 6-10 expected boolean, integer, float, or string, found length
|
// Error: 6-10 expected boolean, integer, float, or string, found length
|
||||||
#int(10pt)
|
#int(10pt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user