Skip to main content Accessibility help
×
Hostname: page-component-77c89778f8-gq7q9 Total loading time: 0 Render date: 2024-07-22T18:27:52.807Z Has data issue: false hasContentIssue false

5 - Type Conversion, Functions, and Scope

Published online by Cambridge University Press:  05 June 2012

Harley R. Myler
Affiliation:
Lamar University
Get access

Summary

Interpretation of data is an important element in the process of describing how the computer acts upon data. If this interpretation is faulty, control structures will not operate properly or data will be misrepresented on output. The definitions of Fortran and C types were explained in Chapter 3; however, the underlying assumption was that types of variables would not be mixed. In other words, calculations involving real variables would only use real variables, and those involving integers would only use integers. Also, the size of variables, or how large a value a variable can hold, was not considered in any detail other than the observation that a double variable is twice the size of a float, and so forth. This chapter will explore the nature of type mixing and the importance of knowing the usage rules for type conversion.

As you know, a program is a set of instructions to perform a task. Large tasks can require programs of huge scope and size; thus, it is useful to be able to partition programs into logical segments. Subroutines or functions represent a useful way to achieve the partitioning of programs to add readability, manageability, and overall structure to a program. This is not all that functions allow us to achieve, for they also save the programmer from useless repetition of program code that is used often and in various places in a program. Finally, they allow for an elegant and efficient way to include mathematical functions in computer programs.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 1998

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×