Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitwise && logical operations #14

Open
hanusek opened this issue Sep 7, 2021 · 1 comment
Open

Bitwise && logical operations #14

hanusek opened this issue Sep 7, 2021 · 1 comment

Comments

@hanusek
Copy link

hanusek commented Sep 7, 2021

Hello!
I have two problems with expressions.

  1. Library did not recognize booleans.
  2. The function - ez_eval() returns an incorrect value.
    The correct value is 2.

@lnicola @likebike Can you help me?

use fasteval::{EmptyNamespace, ez_eval};

let mut ns = EmptyNamespace;
        
// OK
let value = ez_eval("1 == 1", &mut ns).unwrap();
println!("1 == 1 -> fast_eval: {:?}", value);
assert_eq!(value, 1.0);
       
// 1.
// PROBLEM
let value = ez_eval("true == true", &mut ns).unwrap();
println!("true == true -> fast_eval: {:?}", value);
assert_eq!(value, 1.0);
        
// 2.
// PROBLEM, result = 3 ??
let bitand_text = format!("{} && {}",  b_value, b_mask);
let value = ez_eval(bitand_text.as_str(), &mut ns).unwrap();
println!("bitand_text {} -> fast_eval: {:?}", bitand_text, value);
assert_eq!(value, 2.0);
@lnicola
Copy link
Contributor

lnicola commented Sep 8, 2021

Sorry, I've never used this crate and it hasn't changed in about two years. You might want to look for an alternative, or you could look into the implementation and see what it's doing for boolean and bit ops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants