Go Down

Topic: Converting float to int (Read 16889 times) previous topic - next topic


Ok. Try this:

Code: [Select]
float x = 55.6;
int a;

void setup(){
void draw(){
  x = round(x);
  a = (int)x;
  a = 100 * a / 60;


Jan 26, 2012, 02:41 am Last Edit: Jan 26, 2012, 02:49 am by Theelectronicguy Reason: 1
Tried it, it works but not sure how it helps?
I also added a println of a and the value returned is 93 which seems about right. So it must be the map function that doesnt work?


Dunno. I made /two/ changes: (1) I re-wrote your cast so that it couldn't be confused with a function call and (2) did the mapping the "hard" way.


Jan 26, 2012, 02:51 am Last Edit: Jan 26, 2012, 03:03 am by Theelectronicguy Reason: 1
LOL I should start reading the processing referance:http://processing.org/reference/map_.html

I assumed the map function worked for integers but its the opposite(it works for float).However it was the compiler that told me the wrong thing :).

Thanks a lot for the help :D.

Go Up