Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Pascal (programming language)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Data types=== A Type Declaration in Pascal is used to define a range of values which a variable of that type is capable of storing. It also defines a set of operations that are permissible to be performed on variables of that type. The predefined types are: {| class="wikitable" |- ! Data type ! Type of values which the variable is capable of storing |- | [[integer (computer science)|integer]] | integer (whole) numbers |- | [[floating-point arithmetic|real]] | floating-point numbers |- | [[Boolean type|Boolean]] | the values True or False |- | [[character (computing)|char]] | a single character from an ordered character set |- | [[set (computer science)|set]] | equivalent to an array of [[Boolean type|Boolean]] values |- | [[Array data type|array]] | a countable group of any of the preceding data types, of records, or of other arrays |- | [[Record (computer science)|record]] | A collection of any of the preceding data types or of other records |- | [[string (computer science)|string]] | a sequence or "string" of characters is declared as a "packed array of char" with a starting index of 1. These can be assigned string constants and individual characters can be accessed as elements of the array. |} The range of values allowed for the basic types (except Boolean) is implementation defined. Functions are provided for some data conversions. For conversion of <code>real</code> to <code>integer</code>, the following functions are available: <code>round</code> (using [[Rounding#Rounding_half_away_from_zero|rounding half away from zero]]) and <code>trunc</code> (rounds towards zero). The programmer has the freedom to define other commonly used data types (e.g. byte, string, etc.) in terms of the predefined types using Pascal's type declaration facility, for example :<syntaxhighlight lang="pascal"> type byte = 0..255; signed_byte = -128..127; string = packed array[1..255] of char; </syntaxhighlight> Often-used types like byte and string are already defined in many implementations. Normally the system will use a [[Word (computer architecture)|word]] to store the data. For instance, the {{code|byte}} type may be stored in a machine integer - 32 bits perhaps - rather than an [[8-bit computing|8-bit]] value. Pascal does not contain language elements that allow the basic storage types to be defined more granularly. This capability was included in a number of Pascal extensions and follow-on languages, while others, like [[Modula-2]], expanded the built-in set to cover most machine data types like 16-bit integers. The {{code|packed}} keyword tells the compiler to use the most efficient method of storage for the structured data types: sets, arrays and records, rather than using one [[Word (computer architecture)|word]] for each element. Packing may slow access on machines that do not offer easy access to parts of a word.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Pascal (programming language)
(section)
Add topic