Loading...
Pages: [1]   Go Down
Author Topic: float to int  (Read 439 times)
0 Members and 1 Guest are viewing this topic.
Christopher Warnow
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Is there a way to put values returned from a sin() function into the delay()? Or in other words can one convert float into int?

Thank You

Christopher
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 8
Posts: 3532
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To convert a float to an int, you need to cast it.  That is, something like this:

int i = (int) 5.3;

or:

delay((int) (sin(0.5) * 1000));
Logged

Christopher Warnow
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much. smiley
Works like a charm.
Logged

Pages: [1]   Go Up
Print
 
Jump to: