aboutsummaryrefslogtreecommitdiffstats
path: root/src/eval.rs
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2024-05-31 11:23:32 -0700
committerRose Hogenson <rosehogenson@posteo.net>2024-05-31 11:23:32 -0700
commit46fcf485140bfd3f6d8576d3996770615aef29f0 (patch)
treeb2ae21808e705d38ec4fd8ea1322b6c82e258d15 /src/eval.rs
parent55dfd5ea5ad834fcf636c96662252d450a2d736c (diff)
downloadqc-46fcf485140bfd3f6d8576d3996770615aef29f0.tar.zst
Add a README
Diffstat (limited to 'src/eval.rs')
-rw-r--r--src/eval.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/eval.rs b/src/eval.rs
index a72f271..e40743b 100644
--- a/src/eval.rs
+++ b/src/eval.rs
@@ -179,6 +179,13 @@ impl Num {
}
}
+ pub fn trunc(self) -> Num {
+ match self {
+ Int(i) => Int(i),
+ Float(f) => Int(f as i128),
+ }
+ }
+
pub fn abs(self) -> Num {
match self {
Int(i) => Int(i.abs()),