division in progress

parimala

New Member
******************
openedge 10.2b
windows 7 enterprise
******************

DEFINE VARIABLE i AS INTEGER NO-UNDO.
UPDATE i.
i = i / 10.
MESSAGE "i value is:" i
VIEW-AS ALERT-BOX INFO BUTTONS OK.

for this code,if i give number which has unit's value between 0 to 4 it is giving correctly.(for 33 o/p is 3)

But if i give a number like which has unit digit between 5 to 9,it is taking upper value.(for 37 o/p is 4)

why is it so?

i don't want this o/p.

is there any method/option available in progress like floor and ceil functions in c/c++.
 

TomBascom

Curmudgeon
When a decimal value is assigned to an integer it is rounded.

If you don't want that you can use TRUNCATE() like so:

Code:
define variable i as integer no-undo.

do while true:

  update i.

  display
     i / 10 label "plain division"
    truncate( i / 10, 0 ) label "truncated at 0 decimals"
.

end.
 
Top