# Перевод из двоичной системы в восьмеричную — PureBasic(Бейсик)

```rem перевод из 2 сс в 8 сс
cls
input "Введите двоичное число"; a\$

n = 1: k\$ = "": x\$=""
1- k\$ = MID\$ (a\$, n , 1)
if k\$ = "." then n = n -1: goto 20 else x\$ = x\$ + k\$ : n=n+1: goto 10
20 if n mod 3 = 1 then x\$ = "00" +x\$
if n mod 3 = 2 then x\$ = "0" + x\$
print "Получим число";
for i = 1 to len (x\$) step 3
b\$ = mid\$ (x\$, i , 3)
if b\$ = "000" then b1\$ = "0"
if b\$ = "001" then b1\$ = "1"
if b\$ = "010" then b1\$ = "2"
if b\$ = "011" then b1\$ = "3"
if b\$ = "100" then b1\$ = "4"
if b\$ = "101" then b1\$ = "5"
if b\$ = "110" then b1\$ = "6"
if b\$ = "111" then b1\$ = "7"
print b1\$;
next i
print ".";
for i = n +2 to len (a\$) step 3
if (len (a\$) - n -1 ) mod 3 = 1then a\$ = a\$ = "00"
if (len (a\$) - n -1 ) mod 3 = 2 then a\$ = a\$ = ''0"
y\$ = mid\$ (a\$, i, 3)
if y\$ = "000" then y\$ = "0"
if y\$ = "001" then y\$ = "1"
if y\$ = "010" then y\$ = "2"
if y\$ = "011" then y\$ = "3"
if y\$ = "100" then y\$ = "4"
if y\$ = "101" then y\$ = "5"
if y\$ = "110" then y\$ = "6"
if y\$ = "111" then y\$ = "7"
print y1\$;
next i
end
```