[chuck-users] float to int

Perry Cook prc at cs.princeton.edu
Tue Mar 10 12:32:13 EDT 2020


Also, A more obvious and Java-like way to convert float to int is the built-in function:

Std.ftoi(myFloat) => int myInt;



Sent from my iPhone

> On Mar 10, 2020, at 8:51 AM, chuck-users-request at lists.cs.princeton.edu wrote:
> 
> Send chuck-users mailing list submissions to
>    chuck-users at lists.cs.princeton.edu
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>    https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
> or, via email, send a message with subject or body 'help' to
>    chuck-users-request at lists.cs.princeton.edu
> 
> You can reach the person managing the list at
>    chuck-users-owner at lists.cs.princeton.edu
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of chuck-users digest..."
> 
> 
> Today's Topics:
> 
>   1. Std.fabs() keeps giving float (herman verbaeten)
>   2. Re: Std.fabs() keeps giving float (Jack Atherton)
> 
> ----------------------------------------------------------------------
> From: Jack Atherton <lja at ccrma.stanford.edu>
> To: ChucK Users Mailing List <chuck-users at lists.cs.princeton.edu>
> Subject: Re: [chuck-users] Std.fabs() keeps giving float
> Message-ID:
>    <CAEygkh_FzLPeDuZQCPtgc4e0V=+BJwDU7-H+X8=ku8JJ4ZvkFw at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
> 
> $ is the explicit cast operator -- see
> https://chuck.cs.princeton.edu/doc/language/oper.html
> 
> For example, Std.fabs( timedur ) $ int => period;
> 
> ~Jack
> 
>> On Mon, Mar 9, 2020 at 4:05 PM herman verbaeten <hverb54 at hotmail.com> wrote:
>> 
>> Hi,
>> 
>> In your archives i found a way to cast dur as float. But every attempt to
>> convert float to int
>> failes somehow... Error message:* "[test dur-int.ck
>> <http://dur-int.ck>]:line(4): cannot resolve operator '=>' on types 'float'
>> and 'int'..."*
>> 
>> 4400::ms => dur pduration;
>> int period;
>> pduration/1::samp => float timedur;
>> <<<Std.fabs(timedur) => period>>>;
>> 
>> kind regards,
>> 
>> Herman
>> _______________________________________________
>> chuck-users mailing list
>> chuck-users at lists.cs.princeton.edu
>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>> 



More information about the chuck-users mailing list