[PD] Newbie-ish Math Question

Matt Barber brbrofsvl at gmail.com
Sat Sep 20 00:47:21 CEST 2008


To truncate, simply use [int].  To round, add 0.5 to all the values
before you truncate.  If you need something statistically less biased
(the above method of rounding will round everything with a fractional
value of exactly 0.5 up to the nearest integer, which could cause some
positive drift in certain circumstances) -- you can use [expr
rint($f1)], which I think will round fractional values of 0.5 to the
nearest even integer (5.5 -> 6;  -122.5 -> -122, e.g.).



> Date: Thu, 18 Sep 2008 14:18:36 -0400
> From: Tim Glasgow <rorytate at sympatico.ca>
> Subject: [PD] Newbie-ish Math Question
> To: pd list <pd-list at iem.at>
> Message-ID: <p06240801c4f843707e64@[]>
> Content-Type: text/plain; charset="us-ascii" ; format="flowed"
> Hi there.
>    i've been lurking here for 4 or 5 months now, and this community
> is really excellent; i've learned a lot. But now i have my first
> question: Is there an easy way to make a number like 76.87731 round
> up/down or even just chop off the decimal places? i'm sending these
> numbers as MIDI controller numbers and would like to be able to see
> them the way the MIDI device does, as a simple number between 0 and
> 127.
> --t
> [london, canada]

More information about the Pd-list mailing list