## add x amount to a value

Jul 26, 2013 at 11:36am

# add x amount to a value

Hi,

This may seem extremely simple, but I have been boxing around with max objects for a while now. How do I add or subtract x amount to a number that is already there?

Best,

ana

#257234
Jul 26, 2013 at 12:16pm

Hi Ana,

Have a look at the [+] and [-] objects. You can either type in an argument so that the object will always add or subtract the same amount, for example [+ 10]. Or you can send a number to the right inlet and make it variable. Have a look at Max Tutorial 6 (Max5) for how to perform basic maths operations. Remember, if you want to work with floating point numbers (decimals) then you need to use [+ 0.] (notice the decimal point after zero) as these objects otherwise assume you will only ever want to use integers.

If you’re still stuck after reading the first few tutorials, post your patch here so we can talk you through things step by step. (To post your patch here select everything in the patcher window then select “Copy Compressed” from the Max edit menu and simply paste into your reply!)

#257238
Jul 26, 2013 at 1:35pm

Hi,

yes, I don’t think i formulated the question right. I need to add 30 to a value that changes all the time, and still avoid stack overflow. I try to ise the int object, but I can’t seem to make it work.

ana

#257245
Jul 26, 2013 at 1:37pm

ah, I figured it out:

<code>

– Pasted Max Patch, click to expand. –

</code>

#257246
Jul 26, 2013 at 1:39pm

Key to avoiding stack overflow is to store the output from the addition/subtraction/etc. into the right inlet of the +/-/etc. You will need an intermediary “float” object or flonum since you can’t connect an object’s outlets directly to its inlets.

If you’re not familiar with hot and cold inlets, it’s worth going over the right-to-left ordering tutorials.

Alternatively, you can use the accum object. It deals with addition and multiplication. You may need to give it a floating-point argument to get it to floating-point math. (i.e. “accum 0.”)

#257247

You must be logged in to reply to this topic.