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

Support different number systems #61

Open
voltrevo opened this issue May 16, 2024 · 0 comments
Open

Support different number systems #61

voltrevo opened this issue May 16, 2024 · 0 comments

Comments

@voltrevo
Copy link
Collaborator

At the moment we assume a traditional arithmetic over u32.

Instead we should define a Number trait and allow the user to specify the number system they are using. Additionally we can provide implementations of common number systems.

trait Number {
    fn op(&self, op: Operation, rhs: &Self) -> Self;
    // note: we may want to separate this as prefix_op, infix_op, but that's a separate issue
}

then anything implementing this trait can be used by using it as the constraint on a generic, like this:

fn execute<N: Number>(&self, inputs: &[N]) -> Result<Vec<N>, CircuitError>
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

1 participant