
-----------------------------------
ssr
Mon Feb 28, 2005 1:45 pm

base 10 to base 2
-----------------------------------
This is the program I made in class that converts base 10 number to base 2 
try it lol

 8)  8) 
var count : int := 0
var base_10 : int
var temp : int
put "Enter a number that's base 10."
get base_10
temp := base_10

loop
    count := count + 1
    base_10 := base_10 div 2
    exit when base_10 = 0
end loop
var base_2 : array 1 .. count of int
for ii : 1 .. count
    base_2 (ii) := temp mod 2
    temp := temp div 2
end for
put "The base 2 number is "..
for decreasing x : count .. 1
    put base_2 (x) ..
end for


-----------------------------------
Mazer
Mon Feb 28, 2005 2:24 pm


-----------------------------------
Would you like to know about the easier way to do that?

-----------------------------------
zylum
Mon Feb 28, 2005 3:58 pm


-----------------------------------
you mean:

var base_10 : int
get base_10
put intstr (base_10, 0, 2)

 :lol:

-----------------------------------
ssr
Mon Feb 28, 2005 7:00 pm


-----------------------------------
lolol
tnx guys
I never knew that eh?
 :lol:  :lol:

-----------------------------------
ssr
Mon Feb 28, 2005 7:02 pm


-----------------------------------
well u can say the first post is a explanation of how it was transfered
lol   8)

-----------------------------------
Flikerator
Wed Mar 02, 2005 10:13 pm


-----------------------------------
I don't get it, whats the math behind this? Like what is it for...Lolz

-----------------------------------
Carino
Wed Mar 02, 2005 10:52 pm


-----------------------------------
Just decimal to binary... has no real use really. Unless you like doing calculations in binary.

-----------------------------------
Andy
Thu Mar 03, 2005 8:27 pm


-----------------------------------
rofles... binary has tones of use... if u do alot of contest problems, you'll see alot of problems involving filling bins or disks... and binary is quite useful plus its the fundamentals behind computers.. how can any geek not love binary?

-----------------------------------
ssr
Thu Mar 03, 2005 11:25 pm


-----------------------------------
I agree
binary is very useful when doing programming or wanna know how a computer work
but not common in evryday life 8)

-----------------------------------
Jackywsz
Wed Mar 09, 2005 8:40 pm

BASSES
-----------------------------------
Didn't we do that in class sirui? (sigh...)
so...how do u convert a base 2 to base 7 then? 8)

-----------------------------------
ssr
Wed Mar 09, 2005 8:55 pm


-----------------------------------
BOOHO look at the date first JaCKY!!
it was before we learnt it!!
 :?  8)

-----------------------------------
ssr
Wed Mar 09, 2005 9:08 pm


-----------------------------------
var la:string
var base : int
get la
base:=strint (la,2)
put base

thats change from base 2 to base 10 I think .... :shock:  :roll:

-----------------------------------
Jackywsz
Thu Mar 10, 2005 1:08 pm


-----------------------------------
ok exactly, so how can u convert a base 2 to a base 9 or any odd number basses then? :oops:  :roll:  8)  8)

-----------------------------------
person
Thu Mar 10, 2005 3:56 pm


-----------------------------------
to base 10 to base 9


var base_10 : int
get base_10
put intstr (base_10, 0, 9)


-----------------------------------
ssr
Thu Mar 10, 2005 6:33 pm


-----------------------------------
ok exactly, so how can u convert a base 2 to a base 9 or any odd number basses then? :oops:  :roll:  8)  8)
ok u want teh actual formula?
tsktsk
didnt listen in class did u?
 :lol: 
ok now
base 2 to base 8


100101011
group them first by 3
[100][101][011]
then see 0*1 + 0* 2+ 0*4= 4 the first group is 4
same thing, the second one is 5, the thrid one is 3
thus, the number is 453
 :roll:

-----------------------------------
ssr
Thu Mar 10, 2005 7:07 pm


-----------------------------------
for base 2 to base 16 
same thing as above, except group by 4

for base 10 to 2 look at the code above
for base 10 to 8

divide by 8 and get the reminder reverse it
thats it

PAY ATTTENTION IN CLASS!
Test on monday :)  8)
