|  | |
04-04-2009, 09:36 PM
|
#1 (permalink)
|
Monster Techie Join Date: Oct 2008 Location: Irving, TX Posts: 1,175
| Reading a book about C#. (newbie question) Let's just say I know nothing about programming. I have read some other books but lets just assuming I don't know anything when answering my questions here!
So I have this book called "Beginning C#" and I am using VS 2008. Some I am reading along and just barely into the book. Most the stuff so far is pretty straight forward. Not much about code yet. Mostly just introducing the UI of VS.
So I am at this part where it's introducing Variables. The first part if Simple Types. Every thing at this point is easy understanding then he says this:
"A variable storing "N" bits will allow us to represent any numbers between 0 and (2n - 1). Any numbers above this value will be too big to fit into this variable.
Note - the "n" that is in the parenthesis is suppose to be to the power of 2 but I don't know how to show that in the forum.
Ok so what is he talking about here? I'm totally lost. Is this some sort of math equation I'm suppose to understand or he just trying to tell me that N is a variable that could be any thing I make it? I got so lost here. He was explaining simple stuff then he throws this in there and made me look like a lost puppy!
Check back here when ever you see me post if you want to help me out! I will use this from now on.
__________________ Q6600 OC 3.0, 4870 1GB,750w, 4GB DDR2, T-Power I45, Extreme Audio X-Fi OS: Windows7-64-Pro, Contact Core Freezer, Acer G24"/LG 22" |
| |
04-05-2009, 08:12 PM
|
#2 (permalink)
|
Join Date: Jul 2005 Location: England Posts: 2,158
| Re: Reading a book about C#. (newbie question) Really what he is saying is a simple binary concept. Where n is the size of the variable in bits the number of values that variable can hold can be calculated by the sum 2^n. For example, if your variable is 8 bits it can have a value between 0 and 255 (or 256 values).
__________________ MSI P43 Neo|Enermax Pro82+ 425W|E5200|silent 8500GT|250GB Samsung spinpoint F1|Samsung SATA DVD RW|4GB Corsair|Antec SOLO|openSUSE11 
There are in order of increasing severity: lies, darn lies, statistics, and computer benchmarks. - diskinfo man page |
| |
04-05-2009, 11:25 PM
|
#3 (permalink)
|
Monster Techie Join Date: Oct 2008 Location: Irving, TX Posts: 1,175
| Re: Reading a book about C#. (newbie question) Ok I still don't understand completely but at least I know where he is going with it. I think my lack of not doing any math for many years might be part of the reason...
I'm just going to go with it and keep reading. This book is so big. Tiny print and 1030 pages!!! If I ever finish this, it will be the biggest book I ever read. hahaha
__________________ Q6600 OC 3.0, 4870 1GB,750w, 4GB DDR2, T-Power I45, Extreme Audio X-Fi OS: Windows7-64-Pro, Contact Core Freezer, Acer G24"/LG 22" |
| |
04-06-2009, 07:59 AM
|
#4 (permalink)
|
It's all just 1s and 0s Join Date: Jan 2004 Location: in the lab Posts: 4,410
| Re: Reading a book about C#. (newbie question) What is the binary system?
give this a read, then re-read this thread.
the link should give a better understanding of binary numbers. |
| |
04-06-2009, 12:15 PM
|
#5 (permalink)
|
Monster Techie Join Date: Oct 2008 Location: Irving, TX Posts: 1,175
| Re: Reading a book about C#. (newbie question) That helped out with understanding binary a little more for sure. Thank you for that link
__________________ Q6600 OC 3.0, 4870 1GB,750w, 4GB DDR2, T-Power I45, Extreme Audio X-Fi OS: Windows7-64-Pro, Contact Core Freezer, Acer G24"/LG 22" |
| |
04-06-2009, 07:04 PM
|
#6 (permalink)
|
It's all just 1s and 0s Join Date: Jan 2004 Location: in the lab Posts: 4,410
| Re: Reading a book about C#. (newbie question) do you know which numbers you can represent using 5 bits? |
| |
04-06-2009, 07:12 PM
|
#7 (permalink)
|
Monster Techie Join Date: Oct 2008 Location: Irving, TX Posts: 1,175
| Re: Reading a book about C#. (newbie question) would that be:
00000101?
__________________ Q6600 OC 3.0, 4870 1GB,750w, 4GB DDR2, T-Power I45, Extreme Audio X-Fi OS: Windows7-64-Pro, Contact Core Freezer, Acer G24"/LG 22" |
| |
04-06-2009, 07:16 PM
|
#8 (permalink)
|
Join Date: Jul 2005 Location: England Posts: 2,158
| Re: Reading a book about C#. (newbie question) That would be the representation of 5 but I think the question office_politics was after is "what numbers can be represented by 5 bits" he is looking for a range.
__________________ MSI P43 Neo|Enermax Pro82+ 425W|E5200|silent 8500GT|250GB Samsung spinpoint F1|Samsung SATA DVD RW|4GB Corsair|Antec SOLO|openSUSE11 
There are in order of increasing severity: lies, darn lies, statistics, and computer benchmarks. - diskinfo man page |
| |
04-06-2009, 08:01 PM
|
#9 (permalink)
|
Monster Techie Join Date: Oct 2008 Location: Irving, TX Posts: 1,175
| Re: Reading a book about C#. (newbie question) Oh ok. So 0 to 31 then? Correct?
edit: which is 32 bits
__________________ Q6600 OC 3.0, 4870 1GB,750w, 4GB DDR2, T-Power I45, Extreme Audio X-Fi OS: Windows7-64-Pro, Contact Core Freezer, Acer G24"/LG 22"
Last edited by Chad711; 04-06-2009 at 08:04 PM.
|
| |
04-06-2009, 08:11 PM
|
#10 (permalink)
|
Join Date: Jul 2005 Location: England Posts: 2,158
| Re: Reading a book about C#. (newbie question) Quote:
Originally Posted by Chad711 Oh ok. So 0 to 31 then? Correct? | Correct. Quote:
Originally Posted by Chad711 edit: which is 32 bits | What do you mean? It's 32 different values, yes.
__________________ MSI P43 Neo|Enermax Pro82+ 425W|E5200|silent 8500GT|250GB Samsung spinpoint F1|Samsung SATA DVD RW|4GB Corsair|Antec SOLO|openSUSE11 
There are in order of increasing severity: lies, darn lies, statistics, and computer benchmarks. - diskinfo man page |
| |  | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | |