
-----------------------------------
ZeroPaladn
Tue Sep 20, 2005 1:05 pm

very basic decimal --&gt; binary converter
-----------------------------------
this is my basic decimal to binary converter. im working on a way to go backwards from binary to decimal. its not very user friendly, but hey, whatever.

-----------------------------------
Mr. T
Tue Sep 20, 2005 4:44 pm

Alex's Opinion
-----------------------------------
Good effort.

-----------------------------------
ZeroPaladn
Wed Sep 21, 2005 7:08 am


-----------------------------------
thanks. im going to post the other half of the program (binary --> decimal) later on either today or tomorow when i get to finishing it.

-----------------------------------
codemage
Thu Sep 22, 2005 1:07 pm


-----------------------------------
If this is for school, you'd get brownie points for throwing in hex conversion as well.

binary -> hex -> binary is the easiest conversion of all 3.
Once you have that down, you can 'cheat' by converting

decimal -> binary -> hex
or 
hex -> binary -> decimal

...for conversion between all three.

-----------------------------------
ZeroPaladn
Thu Sep 22, 2005 1:33 pm


-----------------------------------
lolz, yeah but i prefer a challenge instead of going hex/bin. then again, nobody said bin/dec was hard...


Ill do it.

-----------------------------------
zylum
Thu Sep 22, 2005 5:49 pm


-----------------------------------
behold... a function that has the ability to convert from any base to any other base in 1 line of code (minus the function declaration):

fcn baseConverter (x : string, initialBase, resultBase : int) : string
    result intstr ((strint (x, initialBase)), 0, resultBase)
end baseConverter

 :lol:

-----------------------------------
ZeroPaladn
Fri Sep 23, 2005 8:57 am


-----------------------------------
HOLY F***ING S***! sorry for caps but i was going to create a function for each thing (ex binary2hex, binary2decimal, you get the idea), but, wow. Thanks alot zylum

+bits

-----------------------------------
[Gandalf]
Fri Sep 23, 2005 3:05 pm


-----------------------------------
+bits
It just so happens that he is a moderator, and +bits will do nothing, but it's the thought that counts ;).

I am pretty sure your teacher would be happier if you did the conversions using the method you learned, not (basically) a function that already exists to do it.  Sure, "don't recreate something if there's an existing library function to do it for you", but there's also the learning process.

-----------------------------------
ZeroPaladn
Mon Sep 26, 2005 11:03 am


-----------------------------------
lolz, attempting to do waht zylum suggested is harder than i though, so i stuck with the old idea that i had. Lolz, it wouldnt let me give him bits anyways...  :oops:

-----------------------------------
Mr. T
Tue Sep 27, 2005 8:12 pm

Alex's Opinion
-----------------------------------
Lolz, it wouldnt let me give him bits anyways...  :oops:
Mod bit totals are fixed.  :roll:

-----------------------------------
Cervantes
Tue Sep 27, 2005 9:37 pm

Re: Alex's Opinion
-----------------------------------
Lolz, it wouldnt let me give him bits anyways...  :oops:
Mod bit totals are fixed.  :roll:
By which he means the whole donation-modding-of-bits is bugged right now.  You can still give bits to mods.  The difference is our bits go back to 1000 the next time we post.

-----------------------------------
ZeroPaladn
Wed Sep 28, 2005 8:32 am


-----------------------------------
lolz, you learn sumthing every day now dont we? :roll:

EDIT

I didnt know zylum was a mod, grats

-----------------------------------
beard0
Wed Sep 28, 2005 4:37 pm


-----------------------------------
I didnt know zylum was a mod, grats
If someone has 1000 bits exactly, chances are pretty darn good that that person is a mod.

-----------------------------------
wtd
Thu Sep 29, 2005 12:47 pm


-----------------------------------
I didnt know zylum was a mod, grats

He's a stealth mod.  ;)

Not that I would know anything about that...

-----------------------------------
[Gandalf]
Thu Sep 29, 2005 2:45 pm


-----------------------------------
zylum
Moderator
Kick Ass Hacker
Not very stealthy anymore, is he? :o

-----------------------------------
ZeroPaladn
Fri Sep 30, 2005 11:10 am


-----------------------------------
this is what i get for not being on compsci for the entire summer... anyways, i've yet to get much work done on the project, mainly cause its all math (aaaaarrrrrgggggghhhhh!) slowly but surely, its coming tho.

-----------------------------------
[Gandalf]
Fri Sep 30, 2005 7:34 pm


-----------------------------------
Did you get something like so:
var inputNum : int
var binaryOut : array 1 .. 8 of int := init (0, 0, 0, 0, 0, 0, 0, 0)

get inputNum

for count : 1 .. 8
    if inputNum mod 2 = 1 then
        binaryOut (count) := 1
    else
        binaryOut (count) := 0
    end if
    inputNum := inputNum div 2
end for

for decreasing count : 8 .. 1
    put binaryOut (count) ..
end for

Oops, wrong thread, but it's about the same thing anyway :o.
