Re: final message

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...

My expectation (just given the name) would be an implementation of:

public function intdiv(object a, object b)	 
	return floor( floor(a)/ floor(b) ) 
end function 

...and then maybe...

public function intdivr(object a, object b)	 
        object c = floor( floor(a)/ floor(b) ) 
	return { c, a - (b*c) } 
end function 

And mine would more like ...

public function intdiv(object a, object b, integer behave = 1) 
    object t 
    t = abs(a) / abs(b) 
    switch behave do 
       case -1 then 
           return floor(t) 
       case 0 then 
           return round(t) 
       case 1 then 
           return ceil(t) 
       case else 
           fail("Unknown behaviour requested") 
    end switch 
end function 
? intdiv(-8, -3, 1) --> 3 
? intdiv(-8, -3, 0) --> 3 
? intdiv(-8, -3,-1) --> 2 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu