[PD] nearest power of 2

Matt Barber brbrofsvl at gmail.com
Thu Dec 11 23:30:46 CET 2008


This might be silly, but here are three abstractions I made a couple
years or so when I was learning...

the "nearest" one defaults to the higher value for numbers halfway between.


Matt

> Date: Fri, 12 Dec 2008 00:48:48 +0900
> From: "hard off" <hard.off at gmail.com>
> Subject: [PD]  nearest power of 2
> To: "Pd List" <pd-list at iem.kug.ac.at>
> Message-ID:
>        <161320dd0812110748w620d032g7b9bdff22d2f4fe7 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> what's the easiest way for pd to find the nearest power of 2 for any float?
>
>
> so 10 would give a result of 8,
> 53 would give a result of 64,
>
> etc..
>
>
> http://en.wikipedia.org/wiki/Power_of_two#Algorithm_to_convert_any_number_into_nearest_power_of_two_number
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.puredata.info/pipermail/pd-list/attachments/20081212/bb3be031/attachment-0001.htm
>
> ------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nextpowoftwo.pd
Type: application/octet-stream
Size: 881 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20081211/7bc518df/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lastpowoftwo.pd
Type: application/octet-stream
Size: 881 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20081211/7bc518df/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nearestpowoftwo.pd
Type: application/octet-stream
Size: 1439 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20081211/7bc518df/attachment-0002.obj>


More information about the Pd-list mailing list