Numbers
Numbers copied to clipboard
What should be the string format for rational numbers?
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?
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?
["("] [-] 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.