how to "round" numbers to decimal ?


    Aug 17 2006 | 9:36 am
    How to make all numbers in, i.e, a range of n0 to n9, be only n ? (25 -> 20, 17 -> 10...)
    thanks in advance
    f.e -- f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|

    • Aug 17 2006 | 9:50 am
      >How to make all numbers in, i.e, a range of n0 to n9, be only n ? >(25 -> 20, 17 -> 10...) > >thanks in advance
      best
      kasper
    • Aug 17 2006 | 9:51 am
      Is this what you mean?
      Mattijs
    • Aug 17 2006 | 10:19 am
      Hey, great ! Thanks to both of you for these two different ways to do it. That's supercool.
      cheers
      f.e
      f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|
      Mattijs Kneppers wrote: > Is this what you mean? > > #P number 43 175 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > #P number 43 119 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > #P newex 43 156 32 196617 * 10; > #P newex 43 136 31 196617 / 10; > #P connect 1 0 3 0; > #P connect 0 0 1 0; > #P connect 2 0 0 0; > > Mattijs > > >
    • Aug 17 2006 | 10:36 am
      >Hey, great ! Thanks to both of you for these two different ways to do it.
      you could also use expr - for some reason %$i1 does not work in expr, but there must be some logic to it (probably because expr is C-like expression in which modulo is done in a totally different way....)
      best
      kasper -- Kasper T. Toeplitz noise, composition, bass, computer http://www.sleazeArt.com
    • Aug 17 2006 | 5:29 pm
      > you could also use expr - for some reason %$i1 does not work in expr, > but there must be some logic to it (probably because expr is C-like > expression in which modulo is done in a totally different way....)
      correct, use the function rather than the operator. i think it's in the expr help/ref somewhere but i don't have it in front of me (i'm not a C programmer, just an expr user). from memory, i think it's mod($i1,10)
    • Aug 17 2006 | 5:54 pm
      I use this method Mattijs suggests all the time, but with a secondary input hooked up, for variable quantization of the signal. This is by far the most useful little abstraction in my arsenal.
      Quote: f.e wrote on Thu, 17 August 2006 12:19 ---------------------------------------------------- > Hey, great ! Thanks to both of you for these two different ways to do > it. That's supercool. > > cheers > > f.e > > f.e chanfrault | aka | personal computer music > > >>>>>> http://www.personal-computer-music.com > > >>>>>> |sublime music for a desperate people| > > > Mattijs Kneppers wrote: > > Is this what you mean? > > > > #P number 43 175 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > > #P number 43 119 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > > #P newex 43 156 32 196617 * 10; > > #P newex 43 136 31 196617 / 10; > > #P connect 1 0 3 0; > > #P connect 0 0 1 0; > > #P connect 2 0 0 0; > > > > Mattijs > > > > > > > ----------------------------------------------------
    • Aug 17 2006 | 6:56 pm
      >>you could also use expr - for some reason %$i1 does not work in >>expr, but there must be some logic to it (probably because expr is >>C-like expression in which modulo is done in a totally different >>way....) > >correct, use the function rather than the operator. i think it's in >the expr help/ref somewhere but i don't have it in front of me (i'm >not a C programmer, just an expr user). from memory, i think it's > mod($i1,10) >
      actually it was ($i1 %10)
      which gives
      OR
    • Aug 17 2006 | 7:51 pm
      Or you could do:
      expr ($i1/10)*10
      Since everything is expressed in int math, you'll only get 10's. Below is an abstraction that will round to arbitrary decimals/tens, etc. and also handles negative numbers.
      Peter McCulloch
    • Aug 17 2006 | 9:39 pm
      On 17-Aug-2006, at 11:36, f.e wrote:
      > How to make all numbers in, i.e, a range of n0 to n9, be only n ? > (25 -> 20, 17 -> 10...)
      Lots of helpful abstractions.
      maxobjects.com lists f0.round, running on Classic Mac OS, OS X, Pd, and Windows. There may be others (the word "round" matches a lot of items). In case you wanted an external.
      -- P.
      -------------- http://www.bek.no/~pcastine/Litter/ ------------- Peter Castine +--> Litter Power & Litter Bundle for Jitter Universal Binaries on the way iCE: Sequencing, Recording & Interface Building for |home | chez nous| Max/MSP Extremely cool |bei uns | i nostri| http://www.dspaudio.com/ http://www.castine.de
    • Aug 18 2006 | 12:51 am
    • Aug 18 2006 | 11:20 pm
      lround from the lobjects is my favourite, can round to any power of ten..
      ciao,
      Joost.
      On 17 Aug 2006, at 22:39, Peter Castine wrote:
      > On 17-Aug-2006, at 11:36, f.e wrote: > >> How to make all numbers in, i.e, a range of n0 to n9, be only n ? >> (25 -> 20, 17 -> 10...) > > Lots of helpful abstractions. > > maxobjects.com lists f0.round, running on Classic Mac OS, OS X, Pd, > and Windows. There may be others (the word "round" matches a lot of > items). In case you wanted an external. > > -- P. > > -------------- http://www.bek.no/~pcastine/Litter/ ------------- > Peter Castine +--> Litter Power & Litter Bundle for Jitter > Universal Binaries on the way > iCE: Sequencing, Recording & > Interface Building for |home | chez nous| > Max/MSP Extremely cool |bei uns | i nostri| > http://www.dspaudio.com/ http://www.castine.de > >