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: 

Rounding down

Former Member
0 Kudos

Hi,

Anybody know the rounding down decimals without using functional module.If you know means tell me pls.

Thanks

Regards,

Nandha

13 REPLIES 13

Former Member
0 Kudos

Hi,

do like this

write : field DECIMALS d .

regards,

srinivasarao.o

0 Kudos

Decimals only allow p

Thanks

Regards,

Nandha

0 Kudos

while declaring write

data : decimals type p round n

where n is the no of decimals u want to round

Former Member
0 Kudos

Hi nandha,

1.one way is to use decimal.

2. see code (just copy paste)

REPORT abc NO STANDARD PAGE HEADING.

DATA: X TYPE P DECIMALS 3 VALUE '1.267',

Y TYPE F VALUE '125.456E2'.

WRITE: / X DECIMALS 0, "output: 1

/ X DECIMALS 2, "output: 1.27

/ X DECIMALS 5, "output: 1.26700

/ Y DECIMALS 1, "output: 1.3E+04

/ Y DECIMALS 5, "output: 1.25456E+04

/ Y DECIMALS 20. "output: 1.25456000000000E+04

3. u can also use write to WRITE TO a FIELD

( instead of displaying)

Hope it helps.

regards,

amit m.

0 Kudos

Hi,

This one is rounding up .I want rounding down. Decimals default rounding up.

Thanks

Regards,

Nandha

0 Kudos

Hi,

maybe 'floor' can help:

REPORT ztest NO STANDARD PAGE HEADING.

DATA: x TYPE p DECIMALS 3 VALUE '1.267',

z TYPE p DECIMALS 3.

z = floor( x * 100 ) / 100. " DECIMALS 2

WRITE:

/ x DECIMALS 3,

/ x DECIMALS 2,

/ z DECIMALS 2.

regards,

Johann

Former Member
0 Kudos

rounding down is nothing but truncating the decimals part, isn't it? So if the value is 11.2, you want 11 and if the value is 11.9, even then you want 11, correct?

Use TRUNC for the purpose.

0 Kudos

Floor function returns next smallest whole number(rounds down),Ceil function returns next largest whole number(rounds up).are you looking for the same?

I = 3.5

I = CEIL( P ). " 4 - next largest whole number,

I = FLOOR( P ). " 3 - next smallest whole number

thanks,

vamshi

Former Member
0 Kudos

Hi,

Rounding down means

1.267

rounding down 2 parameters

1.26

That it. for this i need format.

Thanks.

Regards

Nandha..

0 Kudos

Hi,

Try to use

data: Num type p decimals 2.

This will give u nearest two places of decimal.

If this works out pelase reward points.

Regards,

Irfan Hussain

0 Kudos

Here is the logic.

Multiply your number by 100. Use TRUNC command to remove everything after the decimal point. Divide the number again with 100, you should get your version rounded number.

Former Member
0 Kudos

Hi,

I want to rounding down

1.266

means

1.25

like this

Regards,

nandha

0 Kudos

I am not sure I understood this. Earlier you said, if the value is 1.267, then the result should be 1.26 and now you say if the value is 1.266, then it should be 1.25. Which one is correct?

Then what will be the rounded down value for 1.20? Or will you just leave it as it is because it is already two decimal number? How about 1.2001, will it be 1.20 or 1.19? Are you always rounding down from and three decimal number to a two decimal number?

Srinivas