How to check if number has a decimal?

ruby

Solution

`%` should work

variable % 1 != 0

Check this RubyFiddle.

Here is a JavaScript fiddle, too.

Problem

I want to specifically check if a given number contains ".5" I'm only dealing with whole numbers and halves (0.5, 1, 1.5, etc).

Original source