diff options
author | Som Snytt <som.snytt@gmail.com> | 2017-01-17 01:32:05 -0800 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2017-01-18 00:25:04 -0800 |
commit | a262aaba15effce48fdba95910bef367f89cafca (patch) | |
tree | 59b7f799a64a9215f8b21153c6f6038c8b92f004 /test/files/neg/literals.scala | |
parent | 827d69d48e96d9add75ce19e06b374610784c936 (diff) | |
download | scala-a262aaba15effce48fdba95910bef367f89cafca.tar.gz scala-a262aaba15effce48fdba95910bef367f89cafca.tar.bz2 scala-a262aaba15effce48fdba95910bef367f89cafca.zip |
SI-10148 Follow Java for float literals
Use `Float.parseFloat` instead of converting from Double.
Error when a value rounds to zero.
Diffstat (limited to 'test/files/neg/literals.scala')
-rw-r--r-- | test/files/neg/literals.scala | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/test/files/neg/literals.scala b/test/files/neg/literals.scala index 3df7f0b408..22d5d9acd1 100644 --- a/test/files/neg/literals.scala +++ b/test/files/neg/literals.scala @@ -1,6 +1,6 @@ /* This took me literally all day. -*/ + */ trait RejectedLiterals { def missingHex: Int = { 0x } // line 4: was: not reported, taken as zero @@ -34,3 +34,14 @@ trait Braceless { def noHexFloat: Double = 0x1.2 // line 34: ';' expected but double literal found. } + +trait MoreSadness { + + def tooTiny: Float = { 0.7e-45f } // floating point number too small + + def twoTiny: Double = { 2.0e-324 } // double precision floating point number too small + + def tooHuge: Float = { 3.4028236E38f } // floating point number too large + + def twoHuge: Double = { 1.7976931348623159e308 } // double precision floating point number too large +} |