View Single Post

   
  #4 (permalink)  
Old 04-10-2008, 12:10 AM
google@devenv.com
 
Posts: n/a
Default Re: Modulo function in progress 4gl

On Aug 2, 12:35 pm, Claus <socaciu.clau...@gmail.com> wrote:
> Actually is not what i wanted.
>
> The problem is to calculate the modulo of a integer number of 30
> digits long.


Hi Claudiu,

Not sure if you are looging at doing this in Progress and if so the
problem will be that it does not support integers of that size, what
you can do is use a decimal and create your own function.

def var aa as dec no-undo.

function fModulo returns dec
(longNum as dec, longNum2 as dec) forward.

aa = 123456789012345678901234567890.

message "ans --> " fModulo (aa,9996614.0).

function fModulo returns dec (longNum as dec, longNum2 as dec).

def var i as int.

if longNum < 2147483647 and
longNum2 < 2147483647 then
return dec(longNum modulo longNum2).

assign longNum = truncate(longNum,0)
longNum2 = truncate(longNum2,0).

return truncate(longNum - (longNum2 * truncate((longNum /
longNum2),0)),0).

end.

Reply With Quote