Hi,
I wanted to know about the rounding algorithm used in Smalltalk for rounding negative float numbers like (23.35)?
thanks
Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig
gsharma84 wrote:Hi,
I wanted to know about the rounding algorithm used in Smalltalk for rounding negative float numbers like (23.35)?
thanks
"Answer an Integer nearest the receiver. Basically,
the rounding follows the definition: N rounded = the
nearest integer I = N + (N sign * 0.5) in the direction
toward zero. So in the cases 0.5 rounded = 1,
-0.5 rounded = -1, 1.5 rounded = 2, -1.5 = -2 and
so on
Return to VA Smalltalk 7.0, 7.5 & 8.0
Users browsing this forum: No registered users and 1 guest