Float rounds by it self

edited April 2017 in Questions about Code

I wanted to calculate the aspect ratio of my screen so I used this code

float aspect;

void setup() {
  fullScreen();
}

void draw() {
  aspect = width/height;
  println(aspect);
}

but it returns a 1? a ran it again on windows calculator to be sure my whole understanding of division wasn't wrong and it is not. So what is happening here?

EDIT: I just realised that it doesn't even round since the answer is 1.778 it should round to 2 right?

Tagged:

Answers

Sign In or Register to comment.