Duby mailing list ? How to cast double to float from Duby?

Hello,

Has the Duby mailing list moved to either google group or JRuby already
?
(or what are the plans ?)

The question I have is: how to convert or cast a double to float from
Duby ?

For instance, I’d like to ensure the following field will be kept as
float:

  @c = 1 / Math.tan(pi * @f / sampleRate)

But here it will be kept as double because Math.tan returns a double:

private double c = 0;

What would be the good way to cast it to float ?

I tried Float.new() but I think it’s not that simple :slight_smile:

Full code is here:
http://github.com/thbar/opaz-plugdk/blob/master/plugins/DubyFilta/DubyTools.duby

– Thibaut

The question I have is: how to convert or cast a double to float from Duby
?

By the way, my current work-around is to simply assign a float param to
the
field first, to force Duby to believe it’s a float:

def recompute_parameters(cutoff:float, resonance:float, mode:int,
sampleRate:float)
# first - temporarily trick duby and force @c to be a float
@c = cutoff

@c = 1 / Math.tan(pi * @f / sampleRate)

I’m sure there’s a better way though :slight_smile:

– Thibaut

On Sun, Feb 14, 2010 at 9:10 AM, Thibaut Barrère
[email protected] wrote:

The question I have is: how to convert or cast a double to float from Duby
?

By the way, my current work-around is to simply assign a float param to the
field first, to force Duby to believe it’s a float:

The current cast syntax should work:

float(my_double)

It may change though, since there’s some difficulties distinguishing
method calls from type cases (e.g. if you have a type named “foo” and
a method name “foo”…which do we pick?).

And FYI, Duby mailing list has not moved…since it turned out Kenai
may not go away completely, I haven’t moved the project artifacts yet.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi Charles,

The current cast syntax should work:

float(my_double)

Works perfectly, thanks!

It may change though, since there’s some difficulties distinguishing
method calls from type cases (e.g. if you have a type named “foo” and
a method name “foo”…which do we pick?).

Sure - that will do the trick in the mean time.

And FYI, Duby mailing list has not moved…since it turned out Kenai
may not go away completely, I haven’t moved the project artifacts yet.

Thanks for the clarification.

– Thibaut