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
Inconsistent numeric conversion behaviour #9767
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9767?orig=1 |
Mike Pheasant (intronic) said:
On one hand, the behaviour seems inconsistent and the suggestion sounds reasonable. On the other hand the behaviour is consistent with the documentation and semantics of the java7 methods.
|
Mike Pheasant (intronic) said: After looking into the Java code, it seems reasonable to add the trim() and make the Scala double/int handling consistent. Notes from java code:
|
@som-snytt said: |
When converting string to numbers, the behaviour between natural numbers and floating points is different with regard to leading and trailing spaces:
The documentation is exactly the same in both cases even though the results are not: http://www.scala-lang.org/api/2.11.8/#scala.collection.immutable.WrappedString. Internally, Java's
parseInt/Long/Float/Double
are used, but perhaps it's a good idea to add a call totrim
in the case of integer types. See source: https://github.com/scala/scala/blob/99a82be91cbb85239f70508f6695c6b21fd3558c/src/library/scala/collection/immutable/StringLike.scalaThe text was updated successfully, but these errors were encountered: