<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Numbers on BareSQL.com</title>
    <link>https://baresql.com/tags/numbers/</link>
    <description>Recent content in Numbers on BareSQL.com</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 26 Oct 2026 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://baresql.com/tags/numbers/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>CAST to INTEGER Fails on MySQL and Rounds Differently on SQLite and PostgreSQL</title>
      <link>https://baresql.com/cast-to-integer-fails-on-mysql-and-rounds-differently-on-sqlite-and-postgresql/</link>
      <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
      <guid>https://baresql.com/cast-to-integer-fails-on-mysql-and-rounds-differently-on-sqlite-and-postgresql/</guid>
      <description>&lt;p&gt;Turning a price into a whole number with &lt;code&gt;CAST(5.7 AS INTEGER)&lt;/code&gt; gives 5 on SQLite and 6 on PostgreSQL and MariaDB. MySQL doesn’t run it at all.&lt;/p&gt;&#xA;&lt;p&gt;SQLite drops the fraction and PostgreSQL and MariaDB round it. MySQL takes only SIGNED and UNSIGNED as integer types in CAST, and PostgreSQL refuses both. Decimals differ as well: SQLite ignores the scale of CAST(x AS DECIMAL(10, 1)) and keeps every digit, and MySQL and MariaDB read DECIMAL without a precision as DECIMAL(10, 0), a whole number.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Dividing Decimals Gives Six Decimal Places on MySQL and Sixteen on PostgreSQL</title>
      <link>https://baresql.com/dividing-decimals-gives-six-decimal-places-on-mysql-and-sixteen-on-postgresql/</link>
      <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
      <guid>https://baresql.com/dividing-decimals-gives-six-decimal-places-on-mysql-and-sixteen-on-postgresql/</guid>
      <description>&lt;p&gt;Split an invoice of 80.50 three ways and MySQL and MariaDB hand back 26.833333, PostgreSQL 26.8333333333333333 and SQLite a floating point number. Most of the time nobody notices. Then a report that adds the shares back up gets a different total on MySQL than on PostgreSQL.&lt;/p&gt;&#xA;&lt;p&gt;MySQL and MariaDB give the result of a decimal division four more decimal places than the dividend has (the div_precision_increment setting) and cut it there. PostgreSQL keeps at least 16 significant digits, and SQLite divides as floating point numbers. Shares of an amount and averages of a DECIMAL column then differ in their last digits.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Division by Zero Is NULL on SQLite and MySQL and an Error on PostgreSQL</title>
      <link>https://baresql.com/division-by-zero-is-null-on-sqlite-and-mysql-and-an-error-on-postgresql/</link>
      <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
      <guid>https://baresql.com/division-by-zero-is-null-on-sqlite-and-mysql-and-an-error-on-postgresql/</guid>
      <description>&lt;p&gt;A report that divides revenue by visits fails on PostgreSQL the first time a page has no visits. On SQLite, MySQL and MariaDB the same row quietly shows NULL.&lt;/p&gt;&#xA;&lt;p&gt;PostgreSQL stops the whole statement. SQLite, MySQL and MariaDB answer NULL, MySQL and MariaDB with a warning, and in INSERT and UPDATE with an error when the strict mode includes ERROR_FOR_DIVISION_BY_ZERO (the default). The remainder operator % behaves the same way.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Integer Division Drops the Fraction on SQLite and PostgreSQL and Keeps It on MySQL</title>
      <link>https://baresql.com/integer-division-drops-the-fraction-on-sqlite-and-postgresql-and-keeps-it-on-mysql/</link>
      <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
      <guid>https://baresql.com/integer-division-drops-the-fraction-on-sqlite-and-postgresql-and-keeps-it-on-mysql/</guid>
      <description>&lt;p&gt;You write an average as &lt;code&gt;SUM(stock) / COUNT(*)&lt;/code&gt;, try it on SQLite and get 3. MySQL gives 3.3333 for the same rows. Both are doing what they were built to do, and they disagree about what dividing two integers means.&lt;/p&gt;&#xA;&lt;p&gt;SQLite and PostgreSQL give an integer result when both sides of / are integers, so 7 / 2 is 3. MySQL and MariaDB always divide as decimals and answer 3.5000. Averages written as SUM(x) / COUNT(*) are where this usually bites: the sum of an integer column is an integer on SQLite and PostgreSQL, so the average loses its fraction there.&lt;/p&gt;</description>
    </item>
    <item>
      <title>LOG With One Argument Is Base 10 on PostgreSQL and the Natural Logarithm on MySQL</title>
      <link>https://baresql.com/log-with-one-argument-is-base-10-on-postgresql-and-the-natural-logarithm-on-mysql/</link>
      <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
      <guid>https://baresql.com/log-with-one-argument-is-base-10-on-postgresql-and-the-natural-logarithm-on-mysql/</guid>
      <description>&lt;p&gt;A score or a scale built on &lt;code&gt;LOG()&lt;/code&gt; shifts when the code moves to another engine, because &lt;code&gt;LOG(100)&lt;/code&gt; doesn’t mean the same logarithm everywhere.&lt;/p&gt;&#xA;&lt;p&gt;LOG(100) is 2 on SQLite and PostgreSQL and 4.605 on MySQL and MariaDB. With two arguments, LOG(b, x) is the logarithm of x to base b on all four. SQLite has LOG, LN, LOG10 and POWER only when it is built with its math functions: the sqlite3 program is by default since version 3.35, and some systems ship it without them.&lt;/p&gt;</description>
    </item>
    <item>
      <title>REAL on PostgreSQL and FLOAT on MySQL Are 4-Byte Floats That Drop Digits</title>
      <link>https://baresql.com/real-on-postgresql-and-float-on-mysql-are-4-byte-floats-that-drop-digits/</link>
      <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
      <guid>https://baresql.com/real-on-postgresql-and-float-on-mysql-are-4-byte-floats-that-drop-digits/</guid>
      <description>&lt;p&gt;Measurements kept in a REAL column on PostgreSQL, or in a FLOAT column on MySQL or MariaDB, come back with fewer digits than went in. The same type names keep them all on the other engines.&lt;/p&gt;&#xA;&lt;p&gt;PostgreSQL’s REAL is a 4-byte float, and so is FLOAT on MySQL and MariaDB, while the other engines store 8 bytes for the same name. 1.23456789 comes back as 1.2345679 or 1.23457.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://baresql.com/images/rule-float-precision.png&#34; alt=&#34;CREATE TABLE t (r REAL, f FLOAT); INSERT INTO t VALUES (1.23456789, 1.23456789); SELECT r, f FROM t, run on four engines: SQLite 3.45.1 1.23456789, 1.23456789; PostgreSQL 16.15 1.2345679, 1.23456789; MySQL 8.0.46 1.23456789, 1.23457; MariaDB 10.11.14 1.23456789, 1.23457.&#34;&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>SQLite Keeps DECIMAL Values as Floats and Sums of Prices Pick Up Rounding Errors</title>
      <link>https://baresql.com/sqlite-keeps-decimal-values-as-floats-and-sums-of-prices-pick-up-rounding-errors/</link>
      <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
      <guid>https://baresql.com/sqlite-keeps-decimal-values-as-floats-and-sums-of-prices-pick-up-rounding-errors/</guid>
      <description>&lt;p&gt;A shop keeps its prices in a &lt;code&gt;DECIMAL(10, 2)&lt;/code&gt; column and checks that an order’s lines add up to its total. On SQLite that check can fail for an order of 0.10 and 0.20.&lt;/p&gt;&#xA;&lt;p&gt;PostgreSQL, MySQL and MariaDB keep DECIMAL values exact, so the sum of 0.1 and 0.2 equals 0.3 there. SQLite has no exact decimal type: it stores 0.1 as the nearest binary fraction, the sum is 0.30000000000000004, and the comparison is false.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The Caret Operator Is a Power on PostgreSQL and a Bitwise XOR on MySQL</title>
      <link>https://baresql.com/the-caret-operator-is-a-power-on-postgresql-and-a-bitwise-xor-on-mysql/</link>
      <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
      <guid>https://baresql.com/the-caret-operator-is-a-power-on-postgresql-and-a-bitwise-xor-on-mysql/</guid>
      <description>&lt;p&gt;A growth formula written as &lt;code&gt;rate ^ years&lt;/code&gt; works on PostgreSQL. On MySQL and MariaDB it still runs and gives numbers that have nothing to do with growth: &lt;code&gt;2 ^ 3&lt;/code&gt; is 1 there.&lt;/p&gt;&#xA;&lt;p&gt;PostgreSQL raises the left side to the power of the right one. MySQL and MariaDB combine the bits of both numbers. SQLite has no ^ operator.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://baresql.com/images/rule-caret-operator.png&#34; alt=&#34;SELECT 2 ^ 3, run on four engines: SQLite 3.45.1 error: unrecognized token: &amp;quot;^&amp;quot;; PostgreSQL 16.15 8; MySQL 8.0.46 1; MariaDB 10.11.14 1.&#34;&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
