HairyFotr / linter

Static Analysis Compiler Plugin for Scala
Apache License 2.0
268 stars 34 forks source link

Modulo by one reporting not strict enough on the type #27

Closed huitseeker closed 8 years ago

huitseeker commented 8 years ago
huitseeker➜huitseeker/tmp/TEst» sbt lint:compile                      [18:43:17]
[warn] /home/huitseeker/tmp/TEst/src/main/scala/Test.scala:2: Taking the modulo by one will return zero.
[warn]   def f(x: Double) = x % 1
[warn]                        ^
[warn] one warning found
[success] Total time: 3 s, completed Nov 6, 2015 6:43:25 PM
huitseeker➜huitseeker/tmp/TEst» cat src/main/scala/Test.scala         [18:43:25]
object Test {
  def f(x: Double) = x % 1
}

Taking the modulo by 1 on a float or double is actually a perfectly valid way to take the fractional part.ty o

Note : I assume Division by 1 is guilty of the same problem, but didn't have time to check.

HairyFotr commented 8 years ago

Nice catch, thanks.

Should be fixed on the snapshot, will make a new release after I take care of a few other things.