Application Development 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: 

the different of the types P and F

Former Member
0 Kudos

hi friends,

what is the different of the types P and F?

thanks

Euyo

6 REPLIES 6

Former Member
0 Kudos

Hi,

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

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

Reward if useful!

0 Kudos

Hi,

Both are used for Floating point data ,

<b>F length is 8 bytes where as P can be upto 16 bytes.

For F you cannot specify the length(Its always fixed), for P you can specify the length and the decimals.

For the type p, the fractional portion is indefinite as well as the length.

Also "fixed point arthmetic" flag of the programs effects P type data where F is not effected.

</b>

Regards,

Sesh

Former Member
0 Kudos

hi

if u want the value more accurately in decimals u can go for type P

i think it shows up to 13 decimal values.....

Former Member
0 Kudos

Hello,

ABAP supports three numeric <b>data types - I, P and F</b>.

<b>Calculations involving type I or F fields correspond more or less directly to machine commands. In contrast, calculations involving packed numbers (type P) are programmed, and thus noticeably slower.</b>

Type I values are integers in the range +/- 2 billion, or, exactly, from -2147483648 to 2147483647. Intermediate results in type I expressions are stored in type I auxiliary fields. Otherwise, type I arithmetic is similar to performing calculations with type<b> P fields</b> without decimal places; division (using the operator /) rounds numbers rather than truncating them. Overflow results in a runtime error.

Type I is typically used for counters, quantities, indexes and offsets such as time periods.

The value range of type<b> P fields</b> depends on their length and the number of decimal places. P fields can be <b>1 to 16 bytes</b> long, with two decimal digits packed into each byte, and one decimal digit and the sign packed into the last byte. There can be up to <b>14 decimal</b> places. Auxiliary fields for intermediate results are always 16 bytes long and can thus hold up to 31 decimal digits. To ensure that the decimal point is correctly calculated, you should always set the program attribute "fixed point arithmetic". Otherwise, all numbers are specified as integers and all intermediate results for the next integer are rounded. If "fixed point arithmetic" is not set, the decimal places defined for the number only appear when outputting with WRITE.

Fixed point arithmetic is decimal arithmetic and is similar to using a pocket calculator or calculating with paper and pencil.

<b>Type P is typically used for sizes, lengths, weights and sums of money.</b>

Rule: If you want to calculate "down to the last penny", you should use the type P.

<b>Type F values range from /- 2.2250738585072014E-308 to 1.7976931348623157E308, as well as the number 0, with an accuracy of at least 15 decimal places.</b>

Regards,

Lijo

Former Member
0 Kudos
  • 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.

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb2fd9358411d1829f0000e829fbfe/content.htm">do refer this</a>

regards,

srinivas

<b>*reward for useful answers*</b>

Former Member
0 Kudos

Hi Euyo,

Both the types P and F are floating point data types. We can use them for storing decimal values.

F : 1 - 8 Bytes of memory

P : 1 - 16 Bytes of memory

F : We can use it for <i><b>arithmetic calculations</b></i> only.

P : We can use it for <i><b>arithmetic calculations</b></i> and can be used for <b><i>selection-screen values</i></b> (parameters and select-options).

Ex: PARAMETERS : Avg type p.

We can not write PARAMETERS: Avg type f.<i></i>

Give reward points if it useful.

Regards,

RAJ.