how to use floor

i dont know how to use floor,in my programme:

int k;
int z;
float x;
int y=13;
void setup() {
pinMode(13,OUTPUT);
pinMode(10,OUTPUT);
}
void loop(){
x=(y-7)/4;
if (x==floor(x))
k=1;
else
k=2;
if (k==1)
digitalWrite(13,HIGH);
else
digitalWrite(10,HIGH);
but when i use it on isis proteus i dont find the right result (for y=13,x=2.5,so x!=floor(x) then k=2, but i found led pin 13 on)
help me please

 x=(y-7)/4;

13 - 7 = 6
6 / 4 = 1

Please use code tags.

Read this before posting a programming question

Please edit your post, select the code, and put it between [code] ... [/code] tags.

You can do that by hitting the "Code" icon above the posting area. It is the first icon, with the symbol: </>

You're getting integer-math'ed.

The intermediate values aren't floats, so the part after the decimal is being dropped.

x=(y-7.0)/4;

will produce different behavior (probably the behavior you're expecting). As it is, it's not turned into a float until the math is done - as integers.

in my programm, i want to know if the result of a function is an integer or no!
[int k,y
float x;
void setup() {
pinMode(13,OUTPUT);
pinMode(10,OUTPUT);}
void loop(){
x=(y-7)/4;
if (x==floor(x)) k=1;//k=1 so x in an integer
else k=2;//k=2 so x is a float]
the result found every time is x intiger when x=(13-7)/4=1.5 this is a float.

That code does not compile.

Please use code tags when posting code.

int k,y
float x;
void setup() {
pinMode(13,OUTPUT);
pinMode(10,OUTPUT);}
void loop(){
  x=(y-7)/4;
  if (x==floor(x)) k=1;//k=1 so x in an integer
  else k=2;//k=2 so x is a float

That code still does not compile.

i dont know what to do, its working in my computer, but it dosnt give a right result

The code you posted above is not working on any computer, because it is incomplete and does not compile

Please, just cut the code from the IDE and post it here in code tags.

  int k,y=13;
  float x;
void setup() {
pinMode(13,OUTPUT);
pinMode(10,OUTPUT);
}
void loop(){
  x=(y-7)/4;
  if (x==floor(x))
  k=1;
  else
  k=2;
  if (k==1)
 digitalWrite(13,HIGH);
  else 
 digitalWrite(10,HIGH);
}

13 - 7 = 6.
6 / 4 = 1

floor(1) == 1, so k ==1, so pin 13 gets written HIGH.

Is that what you see?

yes, but what i want to know, is why (13-7)=6/4=1 when 6/4=1.5

Because all the operands are integers, the arithmetic is integer arithmetic.

so how can i get a float operand from this equation, because i need to khow if my result is an integer or a float

Why not try making one of the operands a "float", as suggested in reply #3?

its done.thank you very much

toutou2525:
so how can i get a float operand from this equation, because i need to khow if my result is an integer or a float

Use "modf" or "fmod"