how to "round" numbers to decimal ?

f.e's icon

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|

Kasper's icon

>How to make all numbers in, i.e, a range of n0 to n9, be only n ?
>(25 -> 20, 17 -> 10...)
>
>thanks in advance

Max Patch
Copy patch and select New From Clipboard in Max.

best

kasper

Mattijs's icon

Is this what you mean?

Max Patch
Copy patch and select New From Clipboard in Max.

Mattijs

f.e's icon

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
>
>
>

Kasper's icon

>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

dlurk's icon

> 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)

Wetterberg's icon

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.

Max Patch
Copy patch and select New From Clipboard in Max.

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
> >
> >
> >
>
----------------------------------------------------

Kasper's icon

>>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

Max Patch
Copy patch and select New From Clipboard in Max.

OR

Max Patch
Copy patch and select New From Clipboard in Max.

Peter McCulloch's icon

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

Max Patch
Copy patch and select New From Clipboard in Max.

Peter Castine's icon

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

Roman Thilenius's icon
Joost Rekveld's icon

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
>
>