test_round Subroutine

subroutine test_round()

Arguments

None

Contents

Source Code


Source Code

subroutine test_round ()
   call lala( [ character(len=256) :: &
   '// test round()                                                               ', &
   'clear                                                                         ', &
   'display(ones(80,1)''*61)                                                       ', &
   'help round; display(ones(80,1)''*95)                                           ', &
   'tally=[0];                                                                    ', &
   'a=magic(10)+rand(10)*ones(10)*0.49;                                           ', &
   'a=magic(5);                // an array of whole numbers                       ', &
   'b=rand(5)-ones(5)*0.49999; // array with everything 0.5 < x > -0.5            ', &
   'c=(a+b);                   // values of a randomly changed by less than +-1/2 ', &
   '                                                                              ', &
   'if c<>a , if round(c)=a, ..                                                   ', &
   '   display(''round of array plus random small fraction PASSED''), ..            ', &
   '   tally=[tally,0], ..                                                        ', &
   'else, ..                                                                      ', &
   '   display(''round of array FAILED''), ..                                       ', &
   '   tally=[tally,1], ..                                                        ', &
   'end;                                                                          ', &
   '                                                                              ', &
   'if round(a-c)=0, ..                                                           ', &
   '   display(''round delta of original and randomized PASSED''), ..               ', &
   '   tally=[tally,0], ..                                                        ', &
   'else, ..                                                                      ', &
   '   display(''round delta of original and randomized FAILED''), ..               ', &
   '   tally=[tally,1], ..                                                        ', &
   'end;                                                                          ', &
   '                                                                              ', &
   'if sum(tally)=0,display(''round PASSED'');else,display(''round FAILED'')          ', &
   '<M,N>=shape(tally)                                                             ', &
   'display(tally(2:N),1)                                                         ', &
   ''])
end subroutine test_round