Well, this was just my first pick and trying to get something to work. I do need it to work generically. The numbers I will be sending to it can be either integers or floats. I just chose to use u64 as a place to start experimenting. Getting this to come into scope is my current problem. Once I can get that working, then I can experiment.
in my Cargo.toml file. and change the exp variable to the usize type. It also worked when I passed an f64 to the pow function. Thanks for your help! Now I have to see if I can incorporate this into my project.....
Would it be better to use the num crate instead of the num_traits crate? I'm not sure what is the difference between the two crates.
I just spent some time browsing crates.io to see if I could find an easy-to-use crate containing functions/methods that perform basic and common numeric operations. For instance, what I really need right now is a function that will round a float to a given decimal place. Haven't found that yet. I also need a function, accepting generic types, that will raise the passed value to a passed exponent. In the posts above you can see that I found a function, pow() in the num_traits crate that will do just that. I think this will work in my current project, but I anticipate that eventually this project is going to need to use exponents that contain decimals. Thus the requirement to use exponents of the usize type is eventually going to break down. Can anyone point me to a crate that contains that kind of math functions?
If you are doing financial calculations then your would need something like bigdecimal or rust_decimal. Not sure which is better but unless you are willing to purchase POWER machine it all would be emulated.
If you are not doing financial calculations then knowing just why you want to round to some decimal place would be nice.
The num crate is a convenience crate re-exporting everything of the num-* crates like num-traits, num-bigint, num-complex. If you only need num-traits, using that instead of the full num crate reduces the time required to build your project.