PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV 25 → WX - Converter decimal -> binario
WX - Converter decimal -> binario
Started by adrianoboller, Aug., 19 2015 10:33 PM - 1 reply
Registered member
3,659 messages
Popularité : +175 (223 votes)
Posted on August, 19 2015 - 10:33 PM
// by Jose Elielson
// converter dec -> bin
x is int = edit_decimal
r is int = 0
y is int = 0
b is string = ""

IF x > 1

LOOP
y = IntegerPart(x/2)

r = x - (y*2)

b = NumToString(r) + b

IF y = 1 THEN
b = "1" + b
BREAK
END
x = y
END
ELSE
b = NumToString(x)
END

Info(b)
Registered member
3,659 messages
Popularité : +175 (223 votes)
Posted on August, 19 2015 - 10:34 PM
// José Elielson
// Binario -> Decimal

// observacao
// colocar o inputmask no Exit do Edit
// edit_binario..InputMask = "regexp:[0-1]{0,16}"


b is string = edit_binario

i is int = 0

k is int = 0

y is int = 0

x is int = 0

j is int = Length(NoSpace(b))

FOR i = j TO 1 STEP -1

y = Val(Middle(b,i,1))

IF y = 1 THEN
x = x + (2^(k))
END

k++
END

Info(x)