[chuck-users] float and float[]

Kassen signal.automatique at gmail.com
Sun Nov 12 09:05:27 EST 2006


>
> What is happening is that the implicit cast of an int to a float that
> happens in non-array land isn't happening inside of the array.


Yes, I got that, that's the problem I wanted to report, also see below for
complications.


Remember that if you put a number on the left then you are
> initializing the values and if you put the numbers in the bracket
> beside the type you are declaring the size of the array.


Yeah, I think I understood that correctly, maybe it didn't come across from
my examples. I tried to simplify those as much as possible but typed them
from memory since I'm on a borowed computer and didn't think it would be
correct to go install ChucK everywhere. This might've been unclear or even
incorect, sorry.

Actually, I think it's a bit more mysterious then what we argeed on above.
I encountered this bug/feature when dealing with a 3x3 array of floats that
I wanted to asign a set of values too. These values went something like
this;

[ [-1.25, -1, -0.75], [0, 1, 0], [1.25, 1, 0.75]] @=> float foo[][];

Asignment kept failing, I kept looking and couldn't find the issue.

This isn't improved by ChucK talking about a "@array" or something along
those lines.

After much frustration I tried asigning the sub-arrarys one by one and
discovered the first went in fine and it was only the second one that caused
a issue. It seems to me that you can asign a array that holds ints to a
array of floats with implicit casting as long as there is at least one float
already in there (notice the integer -1 in the first one, that one seems
fine with ChucK).

I think this should be fine;

 [ [-1.25, -1, -0.75], [0, 1.0, 0], [1.25, 1, 0.75]] @=> float foo[][];

But I think I padded every int in sight with a extra ".0" to be sure.

I hope that clarifies?

Yours,
Kas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20061112/82e78bcb/attachment.htm 


More information about the chuck-users mailing list