From 12febf6f88e62fd70cca1b7a87212dc8c0edb027 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Thu, 30 May 2024 10:45:11 -0700 Subject: Use i128. Why not? --- src/eval.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/eval.rs') diff --git a/src/eval.rs b/src/eval.rs index f8f4c53..4d6ec80 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -2,11 +2,11 @@ use std::fmt::{Display, Formatter}; #[derive(Clone, Copy)] pub enum Num { - Int(i64), + Int(i128), Float(f64), } -pub fn int(i: i64) -> Num { +pub fn int(i: i128) -> Num { Num::Int(i) } @@ -69,7 +69,7 @@ impl Num { return int(q); } } - int((self.as_float() / other.as_float()) as i64) + int((self.as_float() / other.as_float()) as i128) } pub fn modulo(self, other: Num) -> Num { @@ -168,21 +168,21 @@ impl Num { pub fn floor(self) -> Num { match self { Num::Int(i) => int(i), - Num::Float(f) => int(f.floor() as i64), + Num::Float(f) => int(f.floor() as i128), } } pub fn ceil(self) -> Num { match self { Num::Int(i) => int(i), - Num::Float(f) => int(f.ceil() as i64), + Num::Float(f) => int(f.ceil() as i128), } } pub fn round(self) -> Num { match self { Num::Int(i) => int(i), - Num::Float(f) => int(f.round_ties_even() as i64), + Num::Float(f) => int(f.round_ties_even() as i128), } } -- cgit v1.3.1