My simple divide patch doesn't work.. What am I doing wrong?

Feb 16, 2012 at 1:26pm

My simple divide patch doesn't work.. What am I doing wrong?

I'm trying to have the patch output a float, but it seems to be bent on staying an int if anything at all.

[attachment=185523,3369]

Attachments:
  1. Untitled5.png
#61827
Feb 16, 2012 at 1:29pm

you need to tell your divide object to work in float as well.

do [/ 1.] and it’ll work.

#223221
Feb 16, 2012 at 1:33pm

you will have to add a 0. to the division object.
otherwise max ignores the floatingpoint part of a values.

– Pasted Max Patch, click to expand. –

ciao, j

#223222
Feb 16, 2012 at 1:38pm

Yay! Thanks.

#223223
Feb 16, 2012 at 2:18pm

This applies to all arithmetic objects, by the way. A lot of other objects also default to working with ints unless you specify float in the initialization arguments.

The reasons for this lie in the distant past, but there a zillions of patches in the world that rely on that behavior.

#223224
Feb 16, 2012 at 4:25pm

What are the reasons for that – in PD everything is a float and it seems to make patching go a bit smoother – why are ints used at all?

#223225
Feb 16, 2012 at 5:27pm

…and it’s probably not a good idea to use / 0. as your default, obviously.

The reason for having integers and floats is an historical one. Max predates Pd, where our pal Mr. Puckette had the great luxury of just starting over and never having to worry about breaking every patch in the electroacoustic repertoire.

#223226
Feb 16, 2012 at 7:02pm

And the reason that they were used historically was that floating point math came at a great performance cost on the machines that Max was designed for (68K Macs w/o a FPU.)

#223227
Feb 20, 2012 at 12:19pm

@grizzle: Max is not Pd. Pd is not Max.

For all the shared ancestory, assuming one will behave like the other in all ways is a recipe for misunderstanding and disaster.

As for ints: they behave *much* more the way people expect than floats once you get used to the fact that they truncate. No problems with accuracy and the last decimal place being different from what you expect or there being more decimals places that what you expect. And, ints have a much wider range than float-with-integer-accuracy.

In short, there are a lot of reasons, beyond legacy, for using ints.

#223228

You must be logged in to reply to this topic.