I struggled a lot with recursive function when I was first introduced to it
I mean, why can't you just do it in a loop, but meh, it has it advantages sometimes, but i like loops better, and will continue to use them. But you still gotta know how to do recursive, so here it is :)
I'm going to write a program in java that adds from like 1-x
say like 1-5, you can do it easily in a for-loop
but we're going to do it the recursive way
it's not short so hit jump for everything :)
Thursday, December 30, 2010
Wednesday, December 29, 2010
IEEE754 Floating point example
the nasty questions i got on my first test in computer architecture, it isn't so bad if it's like between 1-10, but gosh, she gave us a hard one.
but anyways, just an example to show you how to convert floating point number to base 10
Q:Write IEEE 754 floating point number for
01011100001010001111011
first things first, this thing suppose to have more 0's at the end, but i'm too lazy, so whatever.
here we go.
first, chop your string of 1 and 0s into sections
0 1011 1000 0101 0001 1110 11
0 indicates that it is possitive :D
now look at 1011 1000, covert that into decimal
that's 128+0+32+16+8+0+0+0 = 184
and remember that the exponent is biased 127
so 184 - 127 = 57
now onto the next section 0101 0001 1110 11
ok, so in binary, this strings represent 1.0101 0001 1110 11
so then you'll get
but anyways, just an example to show you how to convert floating point number to base 10
Q:Write IEEE 754 floating point number for
01011100001010001111011
first things first, this thing suppose to have more 0's at the end, but i'm too lazy, so whatever.
here we go.
first, chop your string of 1 and 0s into sections
0 1011 1000 0101 0001 1110 11
0 indicates that it is possitive :D
now look at 1011 1000, covert that into decimal
that's 128+0+32+16+8+0+0+0 = 184
and remember that the exponent is biased 127
so 184 - 127 = 57
now onto the next section 0101 0001 1110 11
ok, so in binary, this strings represent 1.0101 0001 1110 11
so then you'll get
then multiply the whole thing by your biased exponent which is 2^57
then bust our your calculator for this fancy thing, or in my case, i just turned it in as is xD
Tuesday, December 21, 2010
Dream Spark
My school's CS department has a lot of software you can get for free, but the thing is, the office hours is like M-F 9-5, and i usually start doing my homework at 10pm, quite a problem to get those programs at the last minute.
That one time i started homework really late, and my friend told me this website called DreamSpark. It runs by Microsoft, this is where i get all the visual studios and MS Servers the last minute. all you need you .edu email address to verify, and free download! woot!
Programming languages like C/C++, gets iffy in different compilers since there aren't really enforcement like JAVA. so it's best to use whatever your professor uses, in my case, Visual Studio.
Hope this helps fellow students who need Visual Studio, Microsoft Server, or other IDE by microsoft for free :)
That one time i started homework really late, and my friend told me this website called DreamSpark. It runs by Microsoft, this is where i get all the visual studios and MS Servers the last minute. all you need you .edu email address to verify, and free download! woot!
Programming languages like C/C++, gets iffy in different compilers since there aren't really enforcement like JAVA. so it's best to use whatever your professor uses, in my case, Visual Studio.
Hope this helps fellow students who need Visual Studio, Microsoft Server, or other IDE by microsoft for free :)
Wednesday, December 15, 2010
Christmas Tree - Java
once upon a time, I went to this comp sci competition, and there was this problem:
Take an user-input, which is an integer indicating the number of levels in the tree.
and the output should look like this:
Take an user-input, which is an integer indicating the number of levels in the tree.
and the output should look like this:
My java code after the jump :)
Tuesday, December 14, 2010
First post! o_O
HI! Call me Krispy~
I just turned 21 the other day, with some free time on my hand with nothing much to do. i'm not really good at anything, i think of myself a jack of all trades but a master of none, but w/e.
over the years people will come to me for homework help, and to be honest, 9/10 they ask the same/similar questions that i already explained to someone else, so i thought, might as well put it online :)
I just want to share some of my math and comp sci homework here, and maybe some pieces of my life in here.
enjoy your stay!
<3
I just turned 21 the other day, with some free time on my hand with nothing much to do. i'm not really good at anything, i think of myself a jack of all trades but a master of none, but w/e.
over the years people will come to me for homework help, and to be honest, 9/10 they ask the same/similar questions that i already explained to someone else, so i thought, might as well put it online :)
I just want to share some of my math and comp sci homework here, and maybe some pieces of my life in here.
enjoy your stay!
<3
Subscribe to:
Posts (Atom)