Hi there,
I just don't get this one. I have an object (maskxor) with a [mode $1 ( method. I've attached an extra outlet to this object so I can see what its value is, and I have a post("mode = %d", x->mode); to display it in the PD window. The type of x->mode is t_float. Right, so when I change the mode from 0 to 1, I should see 1 on the mode outlet and "mode = 1" in the PD window, right? wrong. I get -1.463894 or something like that on the mode outlet, and -219478567583 or something in the PD window. Can someone pleeeeeease tell me what is going on?
Patch code and pd_linux object enclosed. Best, Ed
Lone Shark "Aviation" out now on http://www.pyramidtransmissions.com http://www.myspace.com/sharktracks
--------------------------------- For ideas on reducing your carbon footprint visit Yahoo! For Good this month.
float (t_float) and int (wich you specified with %d) have an incompatible bit arrangement.
so it is wrong doing:
t_float x = 8.0; post("%d", x);
you surely will get an inconsistent result. better you do an explicit cast:
post("%d", (int)x);
On Sun, 2007-09-16 at 12:41 +0200, federico wrote:
float (t_float) and int (wich you specified with %d) have an incompatible bit arrangement.
so it is wrong doing:
t_float x = 8.0; post("%d", x);
you surely will get an inconsistent result. better you do an explicit cast:
post("%d", (int)x);
Yes, but that doesn't fix Ed's problem, using the explicit cast just gives a different incorrect result. I had a little play with the code and couldn't get it to work either.
I'm also confused by the problem, and curious to know the solution...
Jamie
Yes, but that doesn't fix Ed's problem, using the explicit cast just gives a different incorrect result. I had a little play with the code and couldn't get it to work either.
I'm also confused by the problem, and curious to know the solution...
Jamie
indeed the problem is that he is reading a float as int without cast;
but also he is passing an extra argument (the mode method defined with two arguments, but pd expects only a float)
Hi Jamie, and the devlist,
Turns out you don't need t_symbol *s after all. It is the cause of the problem, but how I'm not sure, so federico was right about the arguments to the method. I'm sure someone told me in Montreal that you needed the symbol, but since it isn't used in the method it makes perfect sense that it's only for calling the method.
Simple really! I'll post to CVS tomorrow when I've tidied up.
thanks for testing and proving I wasn't in a dreamworld - so now to bed ;D Ed
Jamie Bullock jamie@postlude.co.uk wrote: On Sun, 2007-09-16 at 12:41 +0200, federico wrote:
float (t_float) and int (wich you specified with %d) have an incompatible bit arrangement.
so it is wrong doing:
t_float x = 8.0; post("%d", x);
you surely will get an inconsistent result. better you do an explicit cast:
post("%d", (int)x);
Yes, but that doesn't fix Ed's problem, using the explicit cast just gives a different incorrect result. I had a little play with the code and couldn't get it to work either.
I'm also confused by the problem, and curious to know the solution...
Jamie