[PD] converting decimal to binary

patco megalegoland at yahoo.fr
Mon Jun 26 02:51:54 CEST 2006


hello, Marc Lavallée has wrote two abstractions for doing what you are looking for:
  
  http://lists.puredata.info/pipermail/pd-list/2005-08/030459.html
  
  patco~
  
  
  
  

adam armfield <adamairmailed at yahoo.com> a écrit :  this is making my brain hurt... is there an object to
do it automatically?...

for various reasons (mostly due to being on a windows
machine and wanting a quick solution) i'd like to do
this with expr or other built in objects (ruby, py
etc. not really an option as of now)

i've got a snippet of python from the net, would
anyone translate this into an expr for me?
(in return for my eternal gratitude ;-)

def Denary2Binary(n):
    '''convert denary integer n to binary string
bStr'''
    bStr = ''
    if n < 0:  raise ValueError, "must be a positive
integer"
    if n == 0: return '0'
    while n > 0:
        bStr = str(n % 2) + bStr
        n = n >> 1
    return bStr

all the best

adam


 
 
  
___________________________________________________________ 
All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine 
http://uk.docs.yahoo.com/nowyoucan.html

_______________________________________________
PD-list at iem.at mailing list
UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list


 		
---------------------------------
 Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20060626/e11636dd/attachment.htm>


More information about the Pd-list mailing list