According to that, it rounds to the nearest even number.  Shouldn't 9.95
go to 10 then, and 9.85 go to 9.8?

After additional testing with SQLite 3.2.2, I have the following
results:

Round(9.95,1)  -> 9.9    *Rounded Down*
Round(9.85,1)  -> 9.8    *Rounded Down*
Round(9.5,0)   -> 10     *Rounded Up*
Round(9.995,2) -> 9.99   *Rounded Down*

I really see no pattern or sense to the results.

Bob

Envision Information Technologies
Associate
[EMAIL PROTECTED]
v. 608.256.5680
f. 608.256.3780
 

-----Original Message-----
From: Kervin L. Pierre [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 30, 2005 12:18 PM
To: [email protected]
Subject: Re: [sqlite] Unlucky number for the ROUND function


Interesting...

Bankers' Rounding
http://blogs.msdn.com/ericlippert/archive/2003/09/26/53107.aspx

Brass Tilde wrote:
>>From: "Bob Dankert"
> 
> 
>>Using an older version which I compiled, I get 9.9, though it
>>seems it should round up to 10.0?
> 
> 
> This may be dependent upon the math library linked into the
application
> by the compiler used to build SQLite.  Some libraries appear to now be
> using so-called "banking rounding" (though there are other names),
where
> a "5" digit is rounded up or down depending upon the digit immediately
> to its left.  If that digit is odd, it rounds one way, if even, the
> other.  It looks like in this case, 9.95 would round to 9.9, while
9.85
> would likely round to 9.9 as well.  Try rounding 9.85 and see what you
> get.
> 
> Brad
> 
> 
> 
> 
> 
> 
> .
> 

Reply via email to