Re: round
	
	
	
	
"Carl R. White" wrote:
>
> I just can't resist threads like this...  >
> Rolf said:
> function round_gm(atom x) -- Round to greatest magnitude
>     if x < 0 then
>         return floor(x - 0.5)
>     else
>         return floor(x + 0.5)
>     end if
> end function
>
> Rolf's function 'Carl'-ised
>
> Rolf said:
> function round_gm(atom x) -- Round to greatest magnitude
>     if x < 0 then
>         return floor(x - 0.5)
>     else
>         return floor(x + 0.5)
>     end if
> end function
>
> Rolf's function 'Carl'-ised  > function round_gm(object x) -- Round to greatest magnitude
>     return floor(x-.5)*(x<0)+floor(x+.5)*(x>0)
> end function
>
> Carl
Carl, my round() or round_gm() is wrong!! round_gm(-2) returns -3, not
-2 !
"Lewis Townsend" wrote:
>
> I think this will do what you want if I'm understanding your
> question correctly:
>
> function round (object x)
>   return floor (x + 0.5)
> end function
and this is correct.
Have a nice day, Rolf
> function round_gm(object x) -- Round to greatest magnitude
>     return floor(x-.5)*(x<0)+floor(x+.5)*(x>0)
> end function
>
> Carl
Carl, my round() or round_gm() is wrong!! round_gm(-2) returns -3, not
-2 !
"Lewis Townsend" wrote:
>
> I think this will do what you want if I'm understanding your
> question correctly:
>
> function round (object x)
>   return floor (x + 0.5)
> end function
and this is correct.
Have a nice day, Rolf
	
	
		| 
									Not Categorized, Please Help
						 |  |