limiting a float
you can set limits to a number box using the inspector, just click on the object, press cmd i, and you can set the maximum and minimum values there. You could also use the [minimum] and [maximum] objects to do limiting. Is that what you were after?
I think this is more a question about decimal places…
Okay, I see what your getting at. How about this:
----------begin_max5_patcher---------- 583.3oc0W0rbaBCD9L7TvnicnTIwup2xyQmLYDFEGkADLH4D2lIu60R.0tsd rU.aB9BZ1kUq91OVs6xatNf75sLIv66d+vyw4MWGGiJsBmdYGPEc6pRpzXF3 wxZwlJfe2qZnpUOwEqenksR04FLIN.56EhI5EDJSufgAPu662zi0BkfVwL96 tVNsbvc7Bit57m+JZ+QztyVEq8AlflWZ1Er+c6PBWTxTFng1qrdiZPK9fCUx +kY6HbvfG5rT8yFVG50wGUA78.4TwZvevbSKSxDJphWKNVvZhRX+Cu60a5cW W8CeKIVA60cw8PTqXaMGA3adHHL377MljpWhPiitIfiQo3iRonQQoiiT1Tky ZsH5SLKwvQlrA+jx13hObtFNI5Zkq8Eay0BM2sivijsQKyjMaKsggSrzF9Vp 1FFN8ZaULojtl8eIbv.LIKMI9Tbdn4jQwlxaIcBYeTJO9JlwAtvTBgDlljbB JAESNjRPiiRvKNJ4r2+5C7oNZQ1B452EdHgSV4tm5FlRHcbLW5M5TBCQ+zlR HYQLjvEtcuUYM886Iii2htQa2OD8Srce3xqbiI..kbw+9ueFVPq+u4MY8l1U C9suep2dZnfIUbgY9gCrQOlyAF8DunfINLlK3RMMXXJ3Q+.ZKbvKK3PrANyF Zz+byYgCY9fiUerlQ5AYCdfyFdRs.NYyFZRr.MoyFZBs.MQyFZhr.MIKpZfg yFZhuhnoq6Eso4EVqr2kFfrq+9y0sZwDeiHWzIZ7Hnk8Bev9XWs2d2820t3z 0C -----------end_max5_patcher-----------
This limits the example to three and two decimal places respectively
Or use [sprintf]
----------begin_max5_patcher---------- 440.3ocyUF0SBCCDG+4YBeGVZhugj1Ba.9leNLFRgcCJYzszVTThe2s65Fff nKC0vKso2c8t+82t1ssyMAjo4a.CI79vGCCB15rDf1JsDTaHfrRrYVlvfARV AFiXNP5V4zBarni9zdwiiinrctRyUVi7MnzMi2iVauPXmsPplOQCyr9pyhF4 76hJpbZLGW3LE9T8lTqWIUYfEUA+.q4qs0lYGVYkXEVYxCZoHamn7gaes.7U lP1WCYBtg7oKuiu+XTnACnrBqLWcnjGMvKYbhVMD9Dtq26bS4rap6uBYG1Fn 1mckwTJo0vQAu3RworwTnkJaZ3s8FjdAMdiwueCQfwomkQr+bFwh+KYDOs88 QWOHJp8HJMK2oq1CAdLdKhMpoTnPncGVKnm.JwzLrRzuFQ71fH2ARXIcCISE p4mgW8+omxF3eCiyne6SY9rSxjpS9oABrRGGAeS9Z8rZsV0e6R9dcl.FqTgB 5fnJe8MjsOpExjDP8I1kHMk7DOlzy2Ozbg0uIB6X4+eHrnFQL50JwhtHhU0y IJJdFzlpT60j6l8xbc453t90RkesOyDM7rrdKQNKXVcCeL+u5OF -----------end_max5_patcher-----------
yes, i was talking about decimal places. I copy the text and press new from clipboard, but it just shows me the text. I am using Max 4.5…
Isn’t there a way to do this using code? you know? just a function?
(0.595).toFixed(2) === ‘0.59’
There are multiple threads on the board about the idiosyncrasies of binary floating point arithmetic. You need to understand this stuff or Max will bite you where it hurts.
Or [round 0.1].
Nicholas, thank you very much, this is exactly what I need. Only that I really want this as a code I can use in JS. Is there a way to use this function – sprintf – as a command in the JS?
It will just simplify the amount of patchers I will need to use If I’ll be able to this inside the code….
Thank you everybody else too.