|
-
Dec 3rd, 2009, 01:47 PM
#1
Thread Starter
New Member
[RESOLVED] Why should I use certain data types?
Hi, I just wanna ask you some quick question: Why should I use string, integer or decimal? What's so good about them?
-
Dec 3rd, 2009, 02:01 PM
#2
Re: Why should I use certain data types?
 Originally Posted by Xardasster
Hi, I just wanna ask you some quick question: Why should I use string, integer or decimal? What's so good about them?
In what case are you referring to?
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Dec 3rd, 2009, 02:03 PM
#3
Fanatic Member
Re: Why should I use certain data types?
a variable stored as a String datatype will return any character as text
a variable stored as an integer datatype will return a number positive or negative as high as the bit used. default is 32 bit and returns a number from −2,147,483,648 to +2,147,483,647 signed and 0 to +4,294,967,295 unsigned.
Double is much like integer accept it allows the use of decimals.
"Double variables are stored as signed IEEE 64-bit (8-byte) double-precision floating-point numbers ranging in value from -1.79769313486231570E+308 through -4.94065645841246544E-324 for negative values and from 4.94065645841246544E-324 through 1.79769313486231570E+308 for positive values." -MSDN article on Double Datatypes.
-
Dec 3rd, 2009, 02:19 PM
#4
Thread Starter
New Member
Re: Why should I use certain data types?
Well, I'm currently working on a program which needs some bit of text to be outputted in a listbox. Also the program should do any calculations if needed. I have already declared variables for my textboxes and combo boxes to a string but I need a reason why it was the best choice. I have also used integers for counting several items - need reason why it was the best choice. As for the decimals, the program should do calculations for each item I choose from a combo box list or by simply checking the boxes - also need why decimal was the best choice.
-
Dec 3rd, 2009, 02:33 PM
#5
Re: Why should I use certain data types?
 Originally Posted by Xardasster
Well, I'm currently working on a program which needs some bit of text to be outputted in a listbox. Also the program should do any calculations if needed. I have already declared variables for my textboxes and combo boxes to a string but I need a reason why it was the best choice. I have also used integers for counting several items - need reason why it was the best choice. As for the decimals, the program should do calculations for each item I choose from a combo box list or by simply checking the boxes - also need why decimal was the best choice.
I'm not sure I understand what you're talking about. You don't have a choice. If you want to store a string, you use a string. If you want to store a whole number, you use an integer, so on and so on.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Dec 3rd, 2009, 02:40 PM
#6
Re: Why should I use certain data types?
If the data could contain non-numeric text (or numbers with extra leading 0's), you need to use a String - because numeric data types only hold numbers.
If the data is purely numeric then using the right data type saves memory, increases speed, and reduces the chances of errors. Which of the numeric data types you should use depends on the data (it is no good using Integer for numbers with decimal places, or Byte for numbers larger than 255).
-
Dec 3rd, 2009, 02:47 PM
#7
Thread Starter
New Member
Re: Why should I use certain data types?
 Originally Posted by weirddemon
I'm not sure I understand what you're talking about. You don't have a choice. If you want to store a string, you use a string. If you want to store a whole number, you use an integer, so on and so on.
I knew that the question is little awkward... Anyways I just wanted to know why integer is good to store text, why decimal to do calculations and so on. Maybe simple information on these types would help.
P.S Thanks si_the_geek we're getting there
-
Dec 3rd, 2009, 02:50 PM
#8
Re: Why should I use certain data types?
Why do you wear pants, or shorts? Couldn't you just use a shirt as well? Would you use a hammer to put in a screw (properly I might add)? While the alternatives work, they are not the best tool for the job.
-tg
-
Dec 3rd, 2009, 02:52 PM
#9
Re: Why should I use certain data types?
 Originally Posted by Xardasster
Anyways I just wanted to know why integer is good to store text, why decimal to do calculations and so on
First, you wouldn't store text in a variable declared as an integer. Text is generally a string, so you'd use a string.
As for doing calculations, that's not relevant. You'd use a decimal variable to do calculations if there are decimals involved. You'd use integers if integers are involved, etc.
Last edited by weirddemon; Dec 3rd, 2009 at 02:59 PM.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Dec 3rd, 2009, 02:56 PM
#10
Hyperactive Member
Re: Why should I use certain data types?
You can't store text in integers. They are strictly for whole numbers, however you can convert integers to text (strings).
Decimals can include decimals, which is good when you expect the result to be a non-whole number.
"The only thing that interferes with my learning is my education."
-
Dec 3rd, 2009, 05:44 PM
#11
Thread Starter
New Member
Re: Why should I use certain data types?
Mmokay... Thanks for your help guys, I can always count on you
Thread Resolved.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|