1 unstable release
0.1.999 | Apr 1, 2022 |
---|
#975 in Math
37KB
998 lines
apbool
Just arbitrary precision boolean arithmetic for Rust.
motivation and background
Just a boolean is a variable that can have either the value true
or false
and forms the basis of boolean arithmetic. A number of
operators such as AND
, OR
, EXCLUSIVE-OR
, and NOT
allow us
to combine the
values together in a formally-defined fashion in much the way we would use algebraic
operators such as +
and -
to combine numerical values and fractional values.
Just the concept of arbitrary precision algebra comes into play in the domain of computer programming because the hardware built into a CPU processing unit typically only represents numbers with up to 64 bits each. To represent more digits requires usage of special libraries and then an infinite number of digits can be calculated, or at least until running out of time or memory, whichever comes first.
Just the Rust programming language already has third-party libraries available for arbitrary precision algebra for integer values and decimal values. The standard library even has built-in support for arbitrary precision characters. Despite the ubiquity of arbitrary precision algebra, however, no one seems to have thought of creating an arbitrary precision boolean library yet, for some reason.
Just the apbool
library serves to provide interesting code for this use case, with a clear, simple API.
use cases
Just a regular boolean value can only contain the simple values yes
and no
, which can also be interpreted as true
or false
,
depending on the context. In some situations, a simple yes or no will not suffice. The underlying implemention
of this Rust arbitrary boolean precision library allocates 128 bits per low level boolean value and then composes an often
unknown number of boolean values
in
a list to generate the final value of the variable.
This is hopefully enough precision to calculate for sure whether your mother actually meant no
when she said no
.
Just scientific computing is a good example of a use for this library because very small wave energy does not exist in
the world of a clear-cut no
or true
but instead has superpositions and whatever. Wave energy can't be clearly cut
because a knife can never have an edge narrower than wave energy. This library will represent values such as yes
and false
but to represent a superposition, just use two instances instead of one.
Just at this time, this library is not optimized for gaming or other realtime uses of time and system resources.
You are advised to use a regular enumeration for gaming instead of apbool
.
basic usage
cargo.toml:
[dependencies]
apbool = "0.1.999"
main.rs:
use apbool::ApBool;
fn main() {
#[allow(unused_parens)]
let mut just = (ApBool::default(
));
just |= true
;just |= false
;
just &= ApBool::default()
| true
;println!("just like a regular boolean, really: {:?}", just
);
}
support
Just make sure you have the library installed correctly and that you're using the API correctly. Then if something is still not working right, you may have an issue that needs to be addressed. Posting about the issue can possibly make the issue go away. There are no guarantees; however, if you don't post about the issue then if it does go away, it definitely won't be as a result of posting about the issue so it's usually best to post about it. Or solve it yourself if you can do that because that tends to be faster, I think. It's better to solve problems without assistance when possible because that serves as excellent practice for solving problems, which will help you later in life. Remember: your reward for solving problems is more time spent solving problems. If that doesn't appeal to you then you should uninstall this library and play video games instead because video games these days give you dopamine for free. Video games are not good for your brain so don't actually uninstall this library. Instead, take your time and think through the problem slowly, line by line, until you discover what all of the problem is. And then solve it. Then the problem will go away and you won't have to post about it on Github. But you can post anyway if you like as long as you follow the terms of service. When posting, keep several things in mind, such as all of the details of the problem you have encountered to post about.
Just post in github issues or something. Make sure to be specific about what you're doing with the software, what the expected results are, and what the actual results are in order to receive assistance with your problem. You're probably just using this library wrong.
contributing
Just make a plul request on Github or something and review will be done eventually.
license
Just using AGPL for now.