vdm++

How to round a real number?


Say I wanted to round a real number to a natural number, how could I do this in VDM++? The MATH library does not appear to have any function that does this.

Thanks, Ricardo


Solution

  • There is a "floor" operator in VDM. This returns the largest integer that is less than or equal to its argument.

    > p floor 1.23
    = 1
    Executed in 0.034 secs. 
    > p floor -1.23
    = -2
    Executed in 0.002 secs. 
    > p floor 123
    = 123
    Executed in 0.001 secs. 
    >