[PD] Integer part

Mathieu Bouchard matju at artengine.ca
Fri Jun 29 19:22:54 CEST 2007


On Fri, 29 Jun 2007, Carlos Pita wrote:

> how do I get the integer and decimal part of a pd float? I see that 
> there is an [int] object but it works as a memory too, a bit more of 
> what I need.

you mean "a bit more than what I need"? If so, well, in pd, it's normal. 
Lots of pd objects have no way to tell whether a piece of information will 
be used only once, many times, or never. Because of that, nearly every 
right-inlet on Earth is keeping a copy of whichever previous value it got, 
even if that's something 50000000 bytes in size. However, in your case, 
it's just a float, that's 4 bytes, and that's not significant at all 
compared to the amount of memory just required to make any objectbox exist 
and be shown on the screen.

> Maybe I could use [expr~]. Is there any standard or common way of doing 
> this?

[int]

but note that this rounds only towards zero. If you want another kind of 
rounding (such as downwards)... well, pd itself is quite lacking in that 
department, but you have several ways out, including:

[t f f]
  |   |
  |  [wrap]
  |   |
[-    ]

where wrap can be found in the zexy library.

  _ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada


More information about the Pd-list mailing list