Hi,

to convert a float to an int,
you need to explicitly cast the value with
4.8 $ int => int foo;  // foo == 4
(as written here: https://chuck.cs.princeton.edu/doc/language/oper.html)

So you would do something like
pctPosInit $ int => int pctPosInitInt
pctPosInitInt/100*myBuf.samples() => myBuf.pos;

. e
On 01/21/2020 02:08 PM, Mícheál Ó Catháin wrote:
Hi
What is the best way to convert a float to int in the following please?

//I want to set myBuf.pos to a percentage of myBuf.samples()...
//Start playing at say 40% through the total number of samples.

40.0 => float pctPosInit;
pctPosInit/100*myBuf.samples() => myBuf.pos;


This throws the error argument types don't match.
I'm not seeing how to convert the float to an int here.
Thanks for your help!

Micheal


_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

Reply via email to