Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 base 10 to base 2
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ssr




PostPosted: 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
Sponsor
sponsor
Mazer




PostPosted: Mon Feb 28, 2005 2:24 pm   Post subject: (No subject)

Would you like to know about the easier way to do that?
zylum




PostPosted: 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)


Laughing
ssr




PostPosted: Mon Feb 28, 2005 7:00 pm   Post subject: (No subject)

lolol
tnx guys
I never knew that eh?
Laughing Laughing
ssr




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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
Sponsor
sponsor
ssr




PostPosted: 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




PostPosted: 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




PostPosted: Wed Mar 09, 2005 8:55 pm   Post subject: (No subject)

BOOHO look at the date first JaCKY!!
it was before we learnt it!!
Confused 8)
ssr




PostPosted: Wed Mar 09, 2005 9:08 pm   Post subject: (No subject)

code:
var la:string
var base : int
get la
base:=strint (la,2)
put base

thats change from base 2 to base 10 I think .... Shocked Rolling Eyes
Jackywsz




PostPosted: 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? Embarassed Rolling Eyes 8) 8)
person




PostPosted: 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




PostPosted: 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? Embarassed Rolling Eyes 8) 8)

ok u want teh actual formula?
tsktsk
didnt listen in class did u?
Laughing
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
Rolling Eyes
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: