Numbers - as per Java, plus indefinitely long integers are supported, as well as ratios, e.g. 22/7. Floating point numbers with an M suffix are read as BigDecimals.
The enclosed posting reports an unnecessary divergence from "as per Java" that I'd like to fix.
May I please enter an issue to track it and provide a patch? --Steve On Apr 24, 2009, at 6:07 PM, Stephen C. Gilardi wrote:
I noticed today that a series of digits with a trailing decimal point are read by Clojure as an Integer.user=> (class 123.) java.lang.Integer In contrast, Java reads such a number as a double. % javac Foo.java Foo.java:5: possible loss of precision found : double required: int int a = 123.; ^ 1 errorAnother place this comes up is with a number formatted as 123.e4. Currently that's an invalid number in Clojure:user=> (class 123.e4) java.lang.NumberFormatException: Invalid number: 123.e4 java.lang.Exception: Unmatched delimiter: ) user=> Java reads it as 1230000.0To bring Clojure in line with Java for numbers formatted this way, I propose changing the reader to match Java's behavior for these cases. I have a patch which I'll attach to an issue if one is approved.--Steve
smime.p7s
Description: S/MIME cryptographic signature