Hi,

I have this expression in my code:

 if (($a % 0.005) != 0) { ... }

Tehnically i'm just checking modulus. However, i get division by zero warning all the time. Why that happens with this expression? The value 0.005 is not zero. The variable $a can get all kinds of numeric values (e.g. it can be either 2 or 1.234, that's why there is a check).

Thanks

I doubt modulus is intended to be used with floating point. Your value gets cast to an int, and is therefor zero.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.