-
Notifications
You must be signed in to change notification settings - Fork 189
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
How to use this library? [integer literal is too large] #249
Comments
You can't directly write that as a numeric literal because we're not integrated in the language or compiler, but you can parse that number from a string: let int: BigInt = "99999999999999999999999999999999999999999999999999"
.parse()
.unwrap(); // for unknown input, might want to handle errors better here |
Do you know any resource/guide that could help me to understand doing arithmetic operations like add, sub, mul, etc with big numbers in rust. I want to know more about this library but there's nothing in |
I don't know any better resources, and no doubt we could use more documentation if someone has the time and skill for writing that. But generally, once you get over this hurdle of creating big numbers, the rest of the normal Rust operators should work fine. Another difference from primitive integers is that let x: BigInt = ...;
// Multiply by reference to create a new `BigInt`, and `x` will still be usable afterward.
let square = &x * &x; Another tip: for numbers that are initially small enough for a primitive integer type, you can also convert them using the |
Thanks I'll try that 👍🏻 |
I want to help with the docs. Where do I start? |
That's an open-ended question! Find something that's confusing and try to clear it up from your perspective as a newer user, or add documentation that you think is completely absent. For this particular issue, the main documentation on |
Thanks for the advice! But should I add stuff to the READMEs, a new folder named "docs", or should I edit in docs.rs? If it's in docs.rs, I need to create an account there (I don't have one, currently). And even after I create an account, I don't know where to "post" my edits (it seems similar to a wiki, so maybe the "edit" button only shows up after login?) |
It would be most visible on docs.rs, but the way you do that is by editing the inline doc comments, here in the code. See https://doc.rust-lang.org/book/ch14-02-publishing-to-crates-io.html#making-useful-documentation-comments |
Thanks again! While reading some more docs, I noticed that (The following is a tangent topic) When I first searched my (The following is on-topic again) So if I understood correctly, to edit docs, I just need to open PRs where I edit doc-comments of any rust-num repo (then await approval and possible merge)? It's that easy?! Then I'm going to start right now! Should I open a monolithic PR? (these usually have big diffs) Or should I open multiple small PRs (1 for each file edited)? |
Note that docs.rs only builds after you publish a new version, and you can see that queue here: https://docs.rs/releases/queue
Yes.
Well, I want to caution you that I'm the only active maintainer on rust-num right now, and I don't have a lot of time to spend reviewing here. So while I appreciate your enthusiasm, please don't flood me with changes too quickly. Let's start with a few small areas that you feel will have large impact, and go from there. |
Ok, understood :) |
Hi, I've looking to assign a big number to an integer in rust with this lib. The docs doesn't clearly mentions how to initialise it.
Following is my code
but it returns this error
I'm new to rust I wanna know how to use it properly. Can you please help?
The text was updated successfully, but these errors were encountered: