Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
41
Добавлен:
16.04.2013
Размер:
4.96 Mб
Скачать

Representing Numeric Data with Number and Floating-Point Datatypes

Pro*C/C++ Support for Native Floating-Point Datatypes

Pro*C/C++ supports the native float and native double datatypes using the column datatypes BINARY_FLOAT and BINARY_DOUBLE. These datatypes can be used in the same way the Oracle NUMBER datatype is used. You can bind the native C/C++ datatypes float and double to BINARY_FLOAT and BINARY_ DOUBLE types respectively. To do so, set the Pro*C/C++ precompiler command line option NATIVE_TYPES to Y (yes) when you compile your application.

Storing Data Using the NUMBER Datatype

Use the NUMBER datatype to store real numbers in a fixed-point or floating-point format. Numbers using this datatype are guaranteed to be portable among different Oracle Database platforms, and offer up to 38 decimal digits of precision. You can store positive and negative numbers of magnitude 1 x 10-130 through 9.99 x10125, as well as zero, in a NUMBER column.

You can specify that a column contains a floating-point number, for example:

distance NUMBER

Or, you can specify a precision (total number of digits) and scale (number of digits to the right of the decimal point):

price NUMBER (8, 2)

Although not required, specifying precision and scale helps to identify bad input values. If a precision is not specified, the column stores values as they are provided. Table 2–5 shows examples of how data different scale factors affect storage.

Table 2–5 How Scale Factors Affect Numeric Data Storage

Input Data

Specified As

Stored As

 

 

 

7,456,123.89

NUMBER

7456123.89

7,456,123.89

NUMBER (9)

7456124

7,456,123.89

NUMBER (9,2)

7456123.89

7,456,123.89

NUMBER (9,1)

7456123.9

7,456,123.89

NUMBER (6)

(not accepted; value exceeds precision)

7,456,123.89

NUMBER (7, -2)

7456100

 

 

 

Selecting a Datatype 2-19

Соседние файлы в папке Oracle 10g