Numbers icon indicating copy to clipboard operation
Numbers copied to clipboard

What should be the string format for rational numbers?

Open peteroupc opened this issue 8 years ago • 2 comments

This library includes an ERational class for arbitrary-precision rational numbers, but doesn't include a way to create an ERational from a string like the other classes EInteger, EDecimal, and EFloat. This is because I'm not sure what format to accept for strings representing rational numbers. Here is a possible idea:

["("] [-] Number "/" [-] Number [")"]

Note that parentheses appear here because Ruby, at least, writes rational number strings this way. How do other languages and popular libraries parse rational number strings? Would it be good to use a string format that combines all of those formats?

peteroupc avatar Jan 18 '16 23:01 peteroupc

Repeating this issue.

This library includes an ERational class for arbitrary-precision rational numbers, but [as of Jan. 18, 2016] doesn't include a way to create an ERational from a string like the other classes EInteger, EDecimal, and EFloat. This is because I'm not sure what format to accept for strings representing rational numbers. Here is a possible idea:

["("] [-] Number "/" [-] Number [")"]

Note that parentheses appear here because Ruby, at least, writes rational number strings this way. How do other languages and popular libraries parse rational number strings? Would it be good to use a string format that combines all of those formats?

peteroupc avatar Jul 30 '18 23:07 peteroupc

["("] [-] Number "/" [-] Number [")"]

This would be good but also spaces should be allowed between these 7 components. The built-in types allow spaces before and after the number, whereas the current ERational.FromString does not. This should be changed.

Happypig375 avatar Jul 08 '20 12:07 Happypig375