Science Fair Projects Ideas - Typecasting (programming)

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

Typecasting (programming)


In computer science, typecasting means to convert a variable's data type to another data type to bypass some restrictions imposed on datatypes. Programming languages that exhibit such a feature of typecasting are C/C++, Java, Applescript, and many other modern or object-oriented programming languages. The expression used in human language is not very complicated to understand, however, understanding typecasting in programming languages is very difficult at first, as it can cause errors in programs if not done right.

Typecasting has risks because typecasting occurs at runtime, as in the compiler just checks to make sure the syntax is correct, but not that the cast will make perfect sense. Therefore, it is necessary to know what type of data a variable is, and to make sure that its target conversion type will make sense and not cause errors. Some examples of safe conversions are floating-point numbers to integers, characters to integers (returns the character's ASCII value), string types to other string types (such as character arrays to an official string data type). Some unsafe casts are floating-point values to characters (since ASCII values are all integers), numerical arrays to character arrays and vice-versa, and contrasting dimension arrays (such as a two dimensional array into a three dimensional array). Often times, a language will have a "safe-cast", in which the compiler/interpreter will try harder to guess at a cast's integrity, and may even have runtime checking so that if a cast throws an error, the cast is ignored. C++ has an implementation of several "safe-casts", such as "static_cast<>", "dynamic_cast<>", "reinterpret_cast<>", and "const_cast<>", all with the target type in the brackets and the source variable in brackets following the keyword.

09-23-2007 01:00:40
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice