SQLite Forum

"Office Space"... I'm losing all those pennies
Login
I suspect the discrepancy has to do with the digits of precision that float has. Float has 24 bits of precision (23 for subnormal) which amounts to 7.22 decimal digits of precision. MariaDB is undoubtedly going the extra mile and performing a rounding step internally before the final conversion to integer. This might be done via a IEEE 754 rounding mode, or it could be something they do in a final analysis.

Where MariaDB is a dedicated process that knows its only reason for existence is to work with a database, it is free to make all the decisions about how to utilize the floating point environment.

SQLite is but one part of a larger process, and defers those decisions to the process. Depending on what platform you are on, it might be possible to set an IEEE 754 rounding mode that would give you the same rounding mode. Alternatively, you could do something like:

SELECT CAST(CAST('16.15' AS FLOAT)*100+0.5 AS INT)

Or use ROUND as was suggested previously.

The long story short is: If all variables are the same, you will get the same answer on both platforms. If anything varies, then you will not.

What platform are you using? Operating system, compiler, runtime library, and versions.