Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Number to binary to number
Message
From
14/06/2006 08:52:02
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
14/06/2006 03:34:28
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01128906
Message ID:
01128961
Views:
18
>Hi All
>
>I have written my own number to binary to number function but I thought I would ask if there was an easier method. I am looking to take number eg 123456 and convert that into a binary string like "00000000000000011110001001000000". Is there a fast way to do this num to char-bin and back to number?

Hi Jos,
Function Bits2Num
  Lparameters tcBinary
  LOCAL ix,lnNum,lnLen
  lnNum = 0
  lnLen = Len(m.tcBinary)
  For ix=1 To Occurs('1',m.tcBinary)
  lnNum = BITSET(m.lnNum, m.lnLen-At('1',m.tcBinary,m.ix))
  endfor
  Return m.lnNum
String operations are slow in VFP and for any language in general. Why do you store it in a bin string? To me it looks like both a storage and performance loss. If you absolutely must and have a need for performance then probably you would want to create a FLL or .Net com for it (like Sedna Net4com)?
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform