PREC constant

authored by electria
This commit is contained in:
Edeth-Baguette 2026-07-13 15:59:14 -07:00
commit e27438a244

View file

@ -13,6 +13,8 @@ enum Error {
NumberParsing(String, ParseFloatError),
}
const PREC: u32 = 512;
#[derive(Clone, Debug, PartialEq)]
enum Node {
Function(Function),
@ -96,7 +98,7 @@ fn nodes_from_str(s: &str) -> Result<Vec<Node>, Error> {
.map_err(|e| {
Error::NumberParsing(filtered_string[start_index..i].to_owned(), e)
})?
.complete(512),
.complete(PREC),
));
state = ParsingState::Start;
@ -138,7 +140,7 @@ fn nodes_from_str(s: &str) -> Result<Vec<Node>, Error> {
.map_err(|e| {
Error::NumberParsing(filtered_string[start_index..i].to_owned(), e)
})?
.complete(512),
.complete(PREC),
));
}
}
@ -153,10 +155,10 @@ fn test_nodes_from_str() {
&[
Node::Function(Function::Sine),
Node::ParenthesisStart,
Node::Number(Float::with_val(512, 2)),
Node::Number(Float::with_val(PREC, 2)),
Node::ParenthesisEnd,
Node::Operator(Operator::Plus),
Node::Number(Float::with_val(512, 1))
Node::Number(Float::with_val(PREC, 1))
],
)
}