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 down

Former Member
0 Likes
2,470

Hi,

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

Thanks

Regards,

Nandha

Hi,

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

Thanks

Regards,

Nandha

13 REPLIES 13
Read only

Former Member
0 Likes
2,318

Hi,

do like this

write : field DECIMALS d .

regards,

srinivasarao.o

Read only

0 Likes
2,318

Decimals only allow p

Thanks

Regards,

Nandha

Read only

0 Likes
2,318

while declaring write

data : decimals type p round n

where n is the no of decimals u want to round

Read only

Former Member
0 Likes
2,318

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.

Read only

0 Likes
2,318

Hi,

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

Thanks

Regards,

Nandha

Read only

0 Likes
2,318

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

Read only

Former Member
0 Likes
2,318

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.

Read only

0 Likes
2,318

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

Read only

Former Member
0 Likes
2,318

Hi,

Rounding down means

1.267

rounding down 2 parameters

1.26

That it. for this i need format.

Thanks.

Regards

Nandha..

Read only

0 Likes
2,318

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

Read only

0 Likes
2,318

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.

Read only

Former Member
0 Likes
2,318

Hi,

I want to rounding down

1.266

means

1.25

like this

Regards,

nandha

Read only

0 Likes
2,318

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