I was working with floating point numbers and integers, and I came across a case where I needed just the part of the floating point number that comes after the decimal. So for example, if I had

what I wanted was just the ".5" part of x, not the 3 in front of it. So I decided to use modular division to get it, like this:Code:float x = 3.5;

So what that would do would divide 3.5 by 1, giving me a remainder of .5, and storing that into partOfX. Yet the compiler for some reason does not allow me to perform modular division on floating point numbers. I tried casting things every which way, got nothing useful. Apparently you can only use modular division with integers.Code:float x = 3.5; float partOfX = x % 1;

So to fix this I just I did some casting to integer and subtraction to get the .5 that I wanted. But I thought it was weird that I couldn't perform modular division on floating point numbers. The calculator program that comes with Windows lets me but I guess Visual C++ 5.0 does not. Perhaps all C/C++ compilers don't.

Anyways, anyone know if its all C/C++ compilers that don't allow modular division with floating point numbers? Or is my compiler just goofy?