Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
25
Task/Binary-digits/Visual-FoxPro/binary-digits.visual
Normal file
25
Task/Binary-digits/Visual-FoxPro/binary-digits.visual
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
*!* Binary Digits
|
||||
CLEAR
|
||||
k = CAST(5 As I)
|
||||
? NToBin(k)
|
||||
k = CAST(50 As I)
|
||||
? NToBin(k)
|
||||
k = CAST(9000 As I)
|
||||
? NToBin(k)
|
||||
|
||||
FUNCTION NTOBin(n As Integer) As String
|
||||
LOCAL i As Integer, b As String, v As Integer
|
||||
b = ""
|
||||
v = HiBit(n)
|
||||
FOR i = 0 TO v
|
||||
b = IIF(BITTEST(n, i), "1", "0") + b
|
||||
ENDFOR
|
||||
RETURN b
|
||||
ENDFUNC
|
||||
|
||||
FUNCTION HiBit(n As Double) As Integer
|
||||
*!* Find the highest power of 2 in n
|
||||
LOCAL v As Double
|
||||
v = LOG(n)/LOG(2)
|
||||
RETURN FLOOR(v)
|
||||
ENDFUNC
|
||||
Loading…
Add table
Add a link
Reference in a new issue