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

Rounding off issue

Former Member
0 Likes
669

Hi All,

In my program there is a stage where i am dividing an amount.

data: var_per type f.

var_per = 1 / 50,00,000.

the variable var_per will be declared as data type f, so taht it can hold even smallest value.

Now, the requirement is to round off the variable 'var_per'.

The value in var_per purely based on the denominator. At sometime, it may be 50,00,000 or even more.

As the denominator increase, the decimal value in var_per increases...

While rounding off, i should take care that, the rounded off figure should not become zero, due to high decimal value.

How to handle such scenario..???

Regards

Pavan

Please search for available information before posting. Thread locked. Points Unassigned

Edited by: kishan P on Sep 1, 2010 3:53 PM

Hi All,

In my program there is a stage where i am dividing an amount.

data: var_per type f.

var_per = 1 / 50,00,000.

the variable var_per will be declared as data type f, so taht it can hold even smallest value.

Now, the requirement is to round off the variable 'var_per'.

The value in var_per purely based on the denominator. At sometime, it may be 50,00,000 or even more.

As the denominator increase, the decimal value in var_per increases...

While rounding off, i should take care that, the rounded off figure should not become zero, due to high decimal value.

How to handle such scenario..???

Regards

Pavan

Please search for available information before posting. Thread locked. Points Unassigned

Edited by: kishan P on Sep 1, 2010 3:53 PM

3 REPLIES 3
Read only

Former Member
0 Likes
524

Hi,

Declare a variable as :

data : p_decimal(16) type p decimals 14.

p_decimal = 1 / 5000000. <-- this will round off and will not return zero.

Regards,

Srini.

Read only

Former Member
0 Likes
524

define data type P.

Read only

prince_isaac
Active Participant
0 Likes
524

Hie Pavan

Use a variable with of type p and here you can also maintain the number of decimal points yo require.


data: xfield type p decimals 2.

regards

Isaac Prince