[PD] converting decimal to binary

adam armfield adamairmailed at yahoo.com
Mon Jun 26 01:21:25 CEST 2006


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




More information about the Pd-list mailing list