Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upNumber to/from string API #6220
Comments
This comment has been minimized.
This comment has been minimized.
|
For comparison, glibc's scanf: floating point, and integers (these are entirely separate). And printf: general number printing and specifically floating point (it actually uses (stack-allocated) GMP bignums). Notably the general number printing is one huge (500 line) macro that gets called twice. |
This comment has been minimized.
This comment has been minimized.
|
Also, I have been working on a generic parser for printf-like format strings. The current grammar is this:
So thinks are specified roughly like: |
This comment has been minimized.
This comment has been minimized.
|
A possibility for code sharing would be having a This would allow float parsing to use the int parsing code to read subsections. (This function might be actually useful for any from_str value.) |
brendanzab
referenced this issue
May 13, 2013
Closed
Integer literals are allowed to be stored in a type which cannot represent them #6450
This comment has been minimized.
This comment has been minimized.
|
I started on writing specialised replacements for ints, uints and floats. Currently the new (u)int versions use a stack allocated vector and a callback function. For the float versions, I started looking into papers and the links here for an optimal algorithm. I will also look into making the number munching thing work. |
huonw
referenced this issue
Jun 9, 2013
Closed
Printing of the largest and other very large floats is wrong #7030
This comment has been minimized.
This comment has been minimized.
|
Two papers about printing floats I saw on Reddit recently: |
huonw
referenced this issue
Aug 27, 2013
Closed
Replace macro impls in libstd/num/strconv.rs with generic impls #4955
brendanzab
added a commit
to brendanzab/rust
that referenced
this issue
Feb 19, 2014
brendanzab
added a commit
to brendanzab/rust
that referenced
this issue
Feb 19, 2014
brendanzab
added a commit
to brendanzab/rust
that referenced
this issue
Feb 19, 2014
brendanzab
added a commit
to brendanzab/rust
that referenced
this issue
Feb 19, 2014
brendanzab
added a commit
to brendanzab/rust
that referenced
this issue
Feb 19, 2014
brendanzab
added a commit
to brendanzab/rust
that referenced
this issue
Feb 19, 2014
brendanzab
added a commit
to brendanzab/rust
that referenced
this issue
Feb 21, 2014
brendanzab
added a commit
to brendanzab/rust
that referenced
this issue
Feb 21, 2014
bors
added a commit
that referenced
this issue
Feb 22, 2014
jxs
added a commit
to jxs/rust
that referenced
this issue
Apr 2, 2014
This comment has been minimized.
This comment has been minimized.
|
I filed a vaguely related RFC for adding scanf-like functionality to Rust - rust-lang/rfcs#67 |
This comment has been minimized.
This comment has been minimized.
|
cc me |
huonw
referenced this issue
Sep 20, 2014
Closed
Extend FromStr by from_{str,bytes}{,_initial} #16176
This comment has been minimized.
This comment has been minimized.
|
Here's a library that's doing something like this: https://github.com/mahkoh/scan |
This comment has been minimized.
This comment has been minimized.
|
@huonw Is there anything actionable here right now, or should this perhaps move to the RFCs repo? |
huonw commentedMay 3, 2013
This is an umbrella issue following on from/working with #4819. The number <-> string conversion needs work and thought.
For example, the current to_str version allocates, and the current from_str doesn't work with the compiler optimisations very well: none of the (for example) exponent parsing code is removed when the function is specialised for
ints.Another important thing to consider is how non-primitive numbers (e.g. bigint/rational) are to be supported/helped (including not at all, other than the normal to/from_str traits)