rohan
In the zone
Well, this tutorial I've made will be updated by me regularly. Recently I got addicted to Scripting thanks to MAKI, the kool scripting language and Vb. Then I thought there were many things that could very well, confuse new scripters and hence I thought this tutorial would help. Please add content to it. I will too... For today, there's one:
DataTypes: Why so many?
Let's consider numbers: Integers, Floats, Doubles, Singles and Booleans.
Integers: Any integeral number between:-2 147 483 647 to +2 147 483 648 That means no decimals EVER
Float: It is a floating point number and can hold upto 4-7 decimal places {depends upon language} A float has a mantissa and an exponent.
Double: It is a floating point number wit h double precision.
Booleans: It can either be 1 or 0 i.e True or Flase or Yes or No.
String: It is a piece of text that cannot be computed mathematically.
All these as you see are nothing but numbers. A 0 or 1 can be a boolean, it can be an integer, it can be a float, a double or even a string. But then why does it have to be assigned as a boolean? why can't an integer be signed as a float? There are two reasons for it:-
1.Computing: Let's take the exaple of two integers: 2 and 472 for ex. Let them be assigned as Strings. Then let's add the two strings. You will get 2472. What it does is 'concatenation'. It joins, rather than adding. Do the same with 'hi!' and ' Hello'. You'll get 'hi! Hello'.
Whereas if you add, them as integers you'll get '474' as the result.
2.Space: Each data-type has a specific amount of data-space assigned to it. Even if it is of a smaller size, it will take that much space. Consider your fridge.
You have about 100ml of yellow butter, 200ml of white butter and 300ml of milk. You have various containers. You have 10 100ml containers, 20 200ml containers and 15 300ml containers. The total space in your fridge is the amount of computing space available to your program OR totla available memory. Now, what would leave you with containers, that can furhter accomodate the maximum space and also make the fridge less uncluttered. You'll put the 100ml ting in the 100ml container, 200ml thing in the 200ml container and so on. You wouldn't waste a 300 mL container on a 100ml thing.
Similarly, integers have 8 bytes capacity, floats have 16 bit capacity and so on. Hence to make things effecient, you need to assign the numbers properly. Like, an integer called '21' will be computed as an integer even if it was a 'float', but why waste the other '8 bit'. Even if that much space isn't reuired by your program, it will close the space for other programs too and in high buil-up softwares', such clutters mean 'doomsday'...
[thanX]
©Rohan Prabhu
DataTypes: Why so many?
Let's consider numbers: Integers, Floats, Doubles, Singles and Booleans.
Integers: Any integeral number between:-2 147 483 647 to +2 147 483 648 That means no decimals EVER
Float: It is a floating point number and can hold upto 4-7 decimal places {depends upon language} A float has a mantissa and an exponent.
Double: It is a floating point number wit h double precision.
Booleans: It can either be 1 or 0 i.e True or Flase or Yes or No.
String: It is a piece of text that cannot be computed mathematically.
All these as you see are nothing but numbers. A 0 or 1 can be a boolean, it can be an integer, it can be a float, a double or even a string. But then why does it have to be assigned as a boolean? why can't an integer be signed as a float? There are two reasons for it:-
1.Computing: Let's take the exaple of two integers: 2 and 472 for ex. Let them be assigned as Strings. Then let's add the two strings. You will get 2472. What it does is 'concatenation'. It joins, rather than adding. Do the same with 'hi!' and ' Hello'. You'll get 'hi! Hello'.
Whereas if you add, them as integers you'll get '474' as the result.
2.Space: Each data-type has a specific amount of data-space assigned to it. Even if it is of a smaller size, it will take that much space. Consider your fridge.
You have about 100ml of yellow butter, 200ml of white butter and 300ml of milk. You have various containers. You have 10 100ml containers, 20 200ml containers and 15 300ml containers. The total space in your fridge is the amount of computing space available to your program OR totla available memory. Now, what would leave you with containers, that can furhter accomodate the maximum space and also make the fridge less uncluttered. You'll put the 100ml ting in the 100ml container, 200ml thing in the 200ml container and so on. You wouldn't waste a 300 mL container on a 100ml thing.
Similarly, integers have 8 bytes capacity, floats have 16 bit capacity and so on. Hence to make things effecient, you need to assign the numbers properly. Like, an integer called '21' will be computed as an integer even if it was a 'float', but why waste the other '8 bit'. Even if that much space isn't reuired by your program, it will close the space for other programs too and in high buil-up softwares', such clutters mean 'doomsday'...
[thanX]
©Rohan Prabhu