Difference between revisions of "Real"

From Lazarus wiki
Jump to navigationJump to search
m
 
(corrections, hint to Programmer's Manual and links to wikipedia.)
Line 1: Line 1:
'''real''' is a [[Standard type|standard type]] of the [[Pascal]] Programming language.  It is used to define a floating point number which may contain a decimal point and possibly an exponent, as opposed to a [[Integer]] data type, used to define a whole number.
+
'''real''' is a [[Standard type|standard type]] of the [[Pascal]] programming language.  It is used to represent rational numbers, which may contain a decimal point and an exponent, as opposed to the [[Integer]] data type, used to represent whole numbers.
  
The size may vary from  6 bytes, 48 bits (you may rapresent numbers from 10^-32 to 10^32) to 8 [[bytes]] 68 bits (10^-300 to 10^300).
+
The internal representation of the type real (i. e. number of bytes and byte ordering) and the resulting range and precision are platform dependent.
 +
 
 +
Citation from the FreePascal Programmer's Manual (Chapter 8.2.5 Floating point types):
 +
 
 +
Contrary to Turbo Pascal, where the real type had a special internal format, under Free Pascal the
 +
real type simply maps to one of the other real types. It maps to the double type on processors
 +
which support floating point operations, while it maps to the single type on processors which do
 +
  not support floating point operations in hardware.
 +
 
 +
So, most common is the mapping to double (8 bytes, 64 bit), with 1 sign bit, 11 exponent bits and 52 mantissa bits. The range of numbers is given by the largest positive and smallest negative numbers: ±1.7976931348623157<sup>308</sup>. The smallest positive non-zero and largest negative non-zero numbers are: ±2.2250738585072020×10<sup>−308</sup>.
 +
The 52 mantissa bits translate into a decimal precision of 15 digits.
 +
 
 +
A more detailed description of floating point numbers is given on the wikipedia pages for [http://en.wikipedia.org/wiki/Floating_point floating point numbers] and [http://en.wikipedia.org/wiki/IEEE_754 IEEE 754] .

Revision as of 15:17, 3 February 2007

real is a standard type of the Pascal programming language. It is used to represent rational numbers, which may contain a decimal point and an exponent, as opposed to the Integer data type, used to represent whole numbers.

The internal representation of the type real (i. e. number of bytes and byte ordering) and the resulting range and precision are platform dependent.

Citation from the FreePascal Programmer's Manual (Chapter 8.2.5 Floating point types):

Contrary to Turbo Pascal, where the real type had a special internal format, under Free Pascal the
real type simply maps to one of the other real types. It maps to the double type on processors
which support floating point operations, while it maps to the single type on processors which do
not support floating point operations in hardware.

So, most common is the mapping to double (8 bytes, 64 bit), with 1 sign bit, 11 exponent bits and 52 mantissa bits. The range of numbers is given by the largest positive and smallest negative numbers: ±1.7976931348623157308. The smallest positive non-zero and largest negative non-zero numbers are: ±2.2250738585072020×10−308. The 52 mantissa bits translate into a decimal precision of 15 digits.

A more detailed description of floating point numbers is given on the wikipedia pages for floating point numbers and IEEE 754 .