Author |
Message |
ssr
|
Posted: Mon Feb 28, 2005 1:45 pm Post subject: 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)
code: | 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
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Mazer
|
Posted: Mon Feb 28, 2005 2:24 pm Post subject: (No subject) |
|
|
Would you like to know about the easier way to do that? |
|
|
|
|
|
zylum
|
Posted: Mon Feb 28, 2005 3:58 pm Post subject: (No subject) |
|
|
you mean:
code: | var base_10 : int
get base_10
put intstr (base_10, 0, 2) |
|
|
|
|
|
|
ssr
|
Posted: Mon Feb 28, 2005 7:00 pm Post subject: (No subject) |
|
|
lolol
tnx guys
I never knew that eh?
|
|
|
|
|
|
ssr
|
Posted: Mon Feb 28, 2005 7:02 pm Post subject: (No subject) |
|
|
well u can say the first post is a explanation of how it was transfered
lol 8) |
|
|
|
|
|
Flikerator
|
Posted: Wed Mar 02, 2005 10:13 pm Post subject: (No subject) |
|
|
I don't get it, whats the math behind this? Like what is it for...Lolz |
|
|
|
|
|
Carino
|
Posted: Wed Mar 02, 2005 10:52 pm Post subject: (No subject) |
|
|
Just decimal to binary... has no real use really. Unless you like doing calculations in binary. |
|
|
|
|
|
Andy
|
Posted: Thu Mar 03, 2005 8:27 pm Post subject: (No subject) |
|
|
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? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
ssr
|
Posted: Thu Mar 03, 2005 11:25 pm Post subject: (No subject) |
|
|
I agree
binary is very useful when doing programming or wanna know how a computer work
but not common in evryday life 8) |
|
|
|
|
|
Jackywsz
|
Posted: Wed Mar 09, 2005 8:40 pm Post subject: BASSES |
|
|
Didn't we do that in class sirui? (sigh...)
so...how do u convert a base 2 to base 7 then? 8) |
|
|
|
|
|
ssr
|
Posted: Wed Mar 09, 2005 8:55 pm Post subject: (No subject) |
|
|
BOOHO look at the date first JaCKY!!
it was before we learnt it!!
8) |
|
|
|
|
|
ssr
|
|
|
|
|
Jackywsz
|
Posted: Thu Mar 10, 2005 1:08 pm Post subject: (No subject) |
|
|
ok exactly, so how can u convert a base 2 to a base 9 or any odd number basses then? 8) 8) |
|
|
|
|
|
person
|
Posted: Thu Mar 10, 2005 3:56 pm Post subject: (No subject) |
|
|
to base 10 to base 9
code: |
var base_10 : int
get base_10
put intstr (base_10, 0, 9)
|
|
|
|
|
|
|
ssr
|
Posted: Thu Mar 10, 2005 6:33 pm Post subject: (No subject) |
|
|
Jackywsz wrote: ok exactly, so how can u convert a base 2 to a base 9 or any odd number basses then? 8) 8)
ok u want teh actual formula?
tsktsk
didnt listen in class did u?
ok now
base 2 to base 8
code: |
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
| |
|
|
|
|
|
|