Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

datatypes

Former Member
0 Likes
730

hai sir

what is difference bt float and packed decimals...

6 REPLIES 6
Read only

Former Member
0 Likes
660

Hi,

Packed Numbers

The valid length for packed numbers is between 1 and 16 bytes;

two decimal places are packed into one byte, whereby the last byte

only contains one place and the plus/minus sign;

after the decimal separator, up to 14 decimal places are permitted.

Depending on the field length len and the number of decimal places dec,

the following applies for the value area:

(-10(2len -1) +1) / (10(dec)) to (10(2len -1) -1) /(10(+dec)) in steps of 10^(-dec).

Values in between this range are rounded off.

Floating point numbers

Floating point numbers are displayed internally with 16 decimal places

according to the IEEE-754 standard (double precision).

Valid values are -1,7976931348623157EE+308 to -2,2250738585072014EE-308

for the negative area,

the value zero,

and +2,2250738585072014EE-308 to 1,7976931348623157EE308

for the positive area.

Both validity areas are extended in the direction of zero

through denormalized numbers after IEEE-754.

Best Wishes,

Raja.

Reward Points if Useful.

Read only

Former Member
0 Likes
660

Hello,

Field Data Type: It cannot be declared in parameters.

Packed Data Type: It can be declared in parameters.In this,

Default Field Length is twice the defined field length,if decimal places are defined, the default field length is increased by 1 so that it is 2 * field length + 1.For ex.

PARAMETERS: A(4) TYPE P DECIMALS 2.

B(4) TYPE P DECIMALS 2.

DATA:C(4) TYPE P DECIMALS 2.

C = A + B.

WRITE:/ 'THE SUM IS',C.

Rewards points if helpful,

Aastha

Read only

Former Member
0 Likes
660

hi there...

Float Data Type: It cannot be declared in Parameters.

Packed Number: It can be declared in Parameters.

For e.g.

PARAMETERS : A(4) TYPE P DECIMALS 2,

B(4) TYPE P DECIMALS 2.

DATA : C(4) TYPE P DECIMALS 2.

C = A + B.

WRITE : / ‘THE SUM IS’ , C.

moreover, i used packed data type to subtract date values to get the number of dates which was not possible using any other data type.

do reward if helpful

Read only

Former Member
0 Likes
660

Hi,

Packed numbers - type P

Type P data allows digits after the decimal point. The number of decimal places is generic, and is determined in the program. The value range of type P data depends on its size and the number of digits after the decimal point. The valid size can be any value from 1 to 16 bytes. Two decimal digits are packed into one byte, while the last byte contains one digit and the sign. Up to 14 digits are allowed after the decimal point. The initial value is zero. When working with type P data, it is a good idea to set the program attribute Fixed point arithmetic.Otherwise, type P numbers are treated as integers.

You can use type P data for such values as distances, weights, amounts of money, and so on.

Floating point numbers - type F

The value range of type F numbers is 1x10*-307 to 1x10*308 for positive and negative numbers, including 0 (zero). The accuracy range is approximately 15 decimals, depending on the floating point arithmetic of the hardware platform. Since type F data is internally converted to a binary system, rounding errors can occur. Although the ABAP processor tries to minimize these effects, you should not use type F data if high accuracy is required. Instead, use type P data.

You use type F fields when you need to cope with very large value ranges and rounding errors are not critical.

with regards,

sowjanya.gosala

Read only

Former Member
0 Likes
660

• Packed numbers - type P

Type P data allows digits after the decimal point. The number of decimal places is generic, and is determined in the program. The value range of type P data depends on its size and the number of digits after the decimal point. The valid size can be any value from 1 to 16 bytes. Two decimal digits are packed into one byte, while the last byte contains one digit and the sign. Up to 14 digits are allowed after the decimal point. The initial value is zero. When working with type P data, it is a good idea to set the program attribute Fixed point arithmetic.Otherwise, type P numbers are treated as integers.

You can use type P data for such values as distances, weights, amounts of money, and so on.

• Floating point numbers - type F

The value range of type F numbers is 1x10*-307 to 1x10*308 for positive and negative numbers, including 0 (zero). The accuracy range is approximately 15 decimals, depending on the floating point arithmetic of the hardware platform. Since type F data is internally converted to a binary system, rounding errors can occur. Although the ABAP processor tries to minimize these effects, you should not use type F data if high accuracy is required. Instead, use type P data.

You use type F fields when you need to cope with very large value ranges and rounding errors are not critical.

Some More:-

Using I and F fields for calculations is quicker than using P fields. Arithmetic operations using I and F fields are very similar to the actual machine code operations, while P fields require more support from the software. Nevertheless, you have to use type P data to meet accuracy or value range requirements.

Read only

Former Member
0 Likes
660

Hi,

Float Data Type: It cannot be declared in Parameters.

Packed Number: It can be declared in Parameters.

More accurate.

Regards,

kavitha