Re: round
	
	
	
	
On Wed, 7 Jun 2000 15:31:59 +0200, Rolf Schroeder <rolf.schroeder at DESY.DE>
wrote:
>"Carl R. White" wrote:
>>
>> 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.
I know.
>> 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.
I know.  That's why I changed the name to 'round_gm' or 'round to
greatest magnitude'. It rounds to the number with the largest _absolute_
value rather than the _largest_ value.
Now, what can we do with  the following function...?
function ceiling(object x) -- mathematical complement of floor()
    return -floor(-x)
end function
Carl
 That's why I changed the name to 'round_gm' or 'round to
greatest magnitude'. It rounds to the number with the largest _absolute_
value rather than the _largest_ value.
Now, what can we do with  the following function...?
function ceiling(object x) -- mathematical complement of floor()
    return -floor(-x)
end function
Carl
	
	
		| 
									Not Categorized, Please Help
						 |  |