2010 Sep 01 10:36 AM
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
2010 Sep 01 10:46 AM
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.
2010 Sep 01 10:50 AM
2010 Sep 01 10:58 AM
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
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |