Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to Transforming numbers into binary number
Message
From
06/04/1998 07:17:25
Matt Mc Donnell
Mc Donnell Software Consulting
Boston, Massachusetts, United States
 
 
To
06/04/1998 06:59:31
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00089725
Message ID:
00089729
Views:
44
CREATEBINARY is not intended to convert base tem numbers to binary. It is used for communication with ActiveX or automation controls.

Use the following simple code:
PARA lnBaseTen

lcReturn = ''

lnWorknum = lnBaseTen

n=0

DO WHILE lnBaseTen>=2^(n+1)
  n=n+1
ENDDO

FOR lnI = n TO 0 STEP -1
  IF lnWorkNum>=2^lnI
    lcReturn = lcReturn + '1'
    lnWorknum = lnWorkNum - 2^lnI
  ELSE
    lcReturn = lcReturn + '0'
  ENDIF
ENDFOR

RETURN lcReturn  
There's probably a better way....there usually is, but it works. :-)
Matt McDonnell
...building a better mousetrap with moldy cheese...
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform