Saturday, January 24, 2015

VARIABLE TYPE

VARIABLE TYPE FOR DATA TYPE

August 2014. About this time, a student needed some tutoring in C. I have not taken a C programming class before and I did not want to take one since C is a subset of C++. I would rather learn C by myself than pay a $300 semester course for C.

I looked at the student’s C program that was not working and tried to debug it. Since I have taken Advanced C++ already, it was not hard to decipher C’s heavy use of pointers or to debug his program. Without pointers C could not do any input and output operations at all.

The concept of variable data type started with C. This is why C is the most successful programming language ever in existence. It’s success is exemplified by all the other languages that adapted its style, particularly C++, Java, Visual Basic, and C#, and by all the popular operating systems of today that uses it, specifically Windows, Mac OS, Linux, and Unix.

Strictly speaking, JavaScript, PHP and Python does not have variable data types as defined in C, C++, C#, Java, SQL and Visual Basic programming languages. HTML and CSS has no variable data type, by definition of variable.

This is the list of primitive data types used by variables in many languages. These data types are particular to Java. All, except byte and boolean, are derived from C and C++.

This program is written in Python, for simplicity.

#Python program that prints the primitive type and their ranges.
print(" boolean range:  true to false                                          ")
print(" char range   :  all original Unicode characters including ASCII        ")
print(" byte range   :  -128 to 127                                            ")
print(" short range  :  -32768 to 32767 or +/- 32K                             ")
print(" int range    :  -2147483648 to 2147483647 or +/- 2 billion             ")
print(" long range   :  -9223372036854775808l to 9223372036854775807L          ")
print("                 or +/- 9 billion billion dollars                       ")
print(" float range  :  1.40129846432481707e-45f to 3.40282346638528860e+38F   ")
print(" double range :  4.94065645841246544e-324d to 1.79769313486231570e+308D ")

C and C++ also has signed and unsigned data types.
C# and VB also has Decimal data type and VB has Single data type.

CYK:
What Java primitive data type is not in C++?
What primitive data type cannot be cast to another data type in Java?
What does a local variable do to a global variable of the same name?

Happy data typing!

John Sindayen

References:
https://msdn.microsoft.com/en-us/library/47zceaw7.aspx
http://zetcode.com/lang/python/datatypes/
http://www.w3schools.com/js/js_datatypes.asp
http://php.net/manual/en/language.types.php
http://zetcode.com/lang/csharp/datatypes/
http://www.tutorialspoint.com/plsql/plsql_data_types.htm
http://www.tizag.com/sqlTutorial/sqlcreate.php
http://stackoverflow.com/questions/7247202/how-to-use-variable-in-css
http://www.w3.org/TR/html4/types.html
http://www.cplusplus.com/doc/tutorial/variables/

No comments:

Post a Comment