this is a simplified part of my query:
select cast(2102.7 * 100000 as integer)
the result is 210269999
I use cast to floor the result and the result should be integer and the value should be 210270000
Why is this happening?
Update
let me ask another way
I have two decimal columns and i want to multiply them and get the floor of the result, for example:
1.2 * 2 = 2.4
floor(2.4) = 2
1.2 * 3 = 3.6
floor(3.6) = 3
this code works
select cast(1.2 * 2 as int)
-------
2
select cast(1.2 * 3 as int)
-------
3
SQLite does not have floor function See. So I am using cast as int. but because of the floating point problems, i cannot get the true floor result for some values, like this
select cast(2102.7 * 100000 as int)
-------
210269999
I dont want to round up the result. and if i use round function as in this, the same problem occurs for some values.
select round(1.2 * 3 - 0.5)
-------
3 (true result)
select round(2102.7 * 100000 - 0.5)
-------
210269999 (false result)
How can I get the true floor for any values?