Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to Transforming numbers into binary number
Message
De
06/04/1998 07:17:25
Matt Mc Donnell
Mc Donnell Software Consulting
Boston, Massachusetts, États-Unis
 
 
À
06/04/1998 06:59:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00089725
Message ID:
00089729
Vues:
45
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...
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform