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

Username:   Password: 
 RegisterRegister   
 Master Number System Coverter [help]
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Flashkicks




PostPosted: Thu Apr 15, 2004 8:44 am   Post subject: Master Number System Coverter [help]

Hi Everyone!! I have posted here a bit long time ago- but it sure has been a while.. My question is; I am wondering if any of you's could help me in providing code for an ultimate converting program. I need a lot of different kinds of converters and am aware that MANY of yous already wrote up topics about this. For moer efficient space I think we should just have all the converters in ONE BIG happy topic family type dealy yo.lol. Here is a list of the ones I already made.. As for the others- Im Just Stumped Confused

[* = one I already made]

Decimal To Binary*
Decimal To Octal
Decimal To Hexadecimal
Binary To Decimal*
Binary To Octal
Binary To Hexadecimal
Octal To Decimal
Octal To Binary
Octal To Hexadecimal
Hexadecimal To Decimal*
Hexadecimal To Binary
Hexadecimal To Octal

Any help would be greatly appreciated.. Thanks for your time. ttyl's
Remember- if anything goes wrong- China is Right below you Wink
~Billy
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Thu Apr 15, 2004 11:45 am   Post subject: (No subject)

It's not that difficult once you have the algorithm down.

It is theoretically possible to make a single algorithm with many variables that would be able to perfom all of the above tasks and many more.

In fact, I just might make one...seeing as I know how to.

Otherwise, if you just want those...then set up a module to handle it. Each procedure would handle each condition, and voilà.
Flashkicks




PostPosted: Fri Apr 16, 2004 8:00 am   Post subject: (No subject)

If you were to make one then that would be amazingly appreciated.. But Im not forcing it upon you; that is of course; if you have the time by All means your welcome to. I on the other do not have the knowledge you do [lol] and am strugling with this project in whole. Hence; i come to you's..lol.. And about making it all in One program-- I thought shampoo And Conditioner IN ONE was awesome enuff!!..lmao...
Tony




PostPosted: Fri Apr 16, 2004 9:47 am   Post subject: (No subject)

Laughing

anyways - the program has been already wrote Wink right here. You could ask sport about how he approached the problem.

Otherwise I'm thinking that you just convert from base to some common base (base 10 for easier understanding and debugging?) and then from that to base of choice. It's not that hard... its the same algorythm for all the bases, the only difference is the size of forloops Razz
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Flashkicks




PostPosted: Mon Apr 19, 2004 7:32 am   Post subject: (No subject)

Thank you very much Tony for applying that handy dandy link and wutnot- but i was wondering; if there is any chance you (or Sport[maker of the program]) could attach the source coding for it. Hence; others who are attempting this project do not have to search the entire forum for source cade~Cuz it will be all right in Here. Iv previously tried searching for it but ittakes me like days to just find a few topics with the help I need. Gathering ALL the information in One Topic would be much more handy.. Thanks very much. For any of you who are wondering; my favorite color in the Fruit Loops cereal is Orange... Laughing
~Billy
Blindmelon_53




PostPosted: Mon Apr 19, 2004 10:04 am   Post subject: (No subject)

One of the main problems that I have especially have been finding when looking for help with number converting is that noone has placed any code(not .exe), as far as I can see, that actually shows how to convert from any to anything other than dec to whatever and whatever to dec. ie hex to binary, octal to hex. It's not that I'm trying to use this site for the knowledge of the peeps so they can do my work for me, but I learn from others through examples such as running source code that I find here to understand how they did what they did. So I think that this will be a great area where we can share our conversion discoveries openly.

What I have done so far (the easy ones of course) Im pretty sure they are all accurate feel free to correct me if im wrong

code:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Decimal to Hex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure DecHex
%Dec to Hex
var num: int := 10
get num
put intstr(num,0, 16)
end DecHex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Hex to Decimal%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure HexDec
%Hex to Dec
var num: string := "FF"
get num
put strint(num, 16)
end HexDec
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Decimal to Binary%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure DecBin
var num : int :=10
put "put  in  a  num: "..
get num
put ""
put intstr(num,0,2)

end DecBin
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%Binary to Decimal%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure BinDec
var num: string
get num
put strint(num,2)
end BinDec
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure DecOct
var num: int
get num
put intstr(num,4,8)
end DecOct
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure OctDec
var num: string
get num
put strint(num,8)
end OctDec
Delos




PostPosted: Mon Apr 19, 2004 11:52 am   Post subject: (No subject)

Argh! That is soooo cheating!!!!!
You used the base function in intstr! How cheap!
!!!
But effective, nonetheless. Of course it would be more...edulcorating if you made an algorithm yourself...but hey, to each their own.

(The other reason I say this is that most teachers won't let students use this method...it requires far less than the intended thinking of this particular problem).
Tony




PostPosted: Mon Apr 19, 2004 12:43 pm   Post subject: (No subject)

so many procedures... Rolling Eyes

can't you just do something like
code:

var base1, base2,dec:int
var num1, num2:string

put "what number?"
get num1
put "is in base"
get base1
put "to be converted to base"
get base2

dec := strint(num1,base1)
num2 := intstr(dec,0,base2)
put "answer is:", num2

Question Thinking
someone tell me if this thing works, I dont have a compiler in school Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
Blindmelon_53




PostPosted: Tue Apr 20, 2004 6:32 am   Post subject: (No subject)

Yea Tony it works great and turns my 53 lines of code into your 13 lines of code and also does more than mine lol. What you had was actually somthing simular to what I wanted to do but I couldn't figure out how to use intstr and strint properly to convert to and from anything other than decimal so I decided I would try and figure out each individually anyways this helps alot. Thanks
Flashkicks




PostPosted: Tue Apr 20, 2004 7:31 am   Post subject: (No subject)

WOW- That was really efficient Tony.. Awesome!!.. Thanks to you greatly for that source code.. Workd absolutely fine and dandy like sugar and candy.. Everyone keep up the good werk and we'll be in touch! Very Happy
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: