! TITLE: round_num.mac (MANAGEMENT) ! ! ! OBJECTIVE: ! ! This sub-macro takes a real (decimal) number and rounds it to a user ! specified number of decimal placesafter the decimal point. ! ! ! COMMAND SYNTAX: ! ! (1) (2) ! ROUND_NUM, num, d_places ! ! ! ARGUMENTS: ! ! num = the number to be rounded. ! ! d_places = the number of decimal after the decimal point ! to round to. ! ! ! DESCRIPTION: ! ! Input the decimal number, in its full precision form, in the 1st argument ! and the the number of desired decimal places to round-off to in the 2nd ! argument. ! ! The rounded number is returned in the parameter: num_ ! ! ! *get,prkey_,active,0,prkey /nopr num_=arg1 dplac_=arg2 ! wholnum_=num_-mod(num_,1) ! decnum_=num_-wholnum_ ! factor_=10**dplac_ ! decnum_=(nint(decnum_*factor_))/factor_ ! num_=wholnum_+decnum_ ! *set,decnum_, *set,dplac_, *set,wholnum_, *set,factor_, *if,prkey_,eq,1,then /go *endif