T&B <[EMAIL PROTECTED]> wrote:
> 
> >> select cast( 141.70 * 100 as integer)
> 
> gives the incorrect 14169

14169 is the correct answer, believe it or not.  There is
no such thing as the number 141.70 in a 64-bit IEEE float.  
The closest you can get is

  141.69999999999998863131622783839702606201171875

which is what SQLite uses internally.  If you multiple
that value by 100 and take the integer part, you are
left with 14169.

 
> but this workaround:
> 
> select cast( round(141.70 * 100, 0) as integer)
> 
> gives the correct: 14170
> 
> Now the question is, does this fix the problem, or only for some  
> numbers?
> 

This should fix your problem.  The round() function takes
the nearest integer rather than simply truncating the fractional
part.

--
D. Richard Hipp <[EMAIL PROTECTED]>


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to