// data type reference

BINARY_FLOAT and binary-float edge cases

Where IEEE floats get weird: NaN, infinity and divide-by-zero per engine.

Missing in
SQL Server
Gotchas
4 listed

Engine by engine

PostgreSQL and Oracle store NaN and infinity as values; MySQL and SQL Server reject them; SQLite keeps infinity but turns NaN into NULL.

BINARY_FLOAT / NaN and infinity in SQL Server, PostgreSQL, MySQL, SQLite and Oracle: type name, storage and notes
Engine Type Storage Notes
SQL Server no separate type - FLOAT(53) Workaround 4-8 bytes IEEE floats, but no NaN or infinity: dividing by zero raises an error rather than producing a value.
PostgreSQL REAL / DOUBLE PRECISION 4-8 bytes IEEE throughout: 'NaN'::float8, 'Infinity' and '-Infinity' all store, and NaN sorts above every number.
MySQL FLOAT / DOUBLE 4-8 bytes IEEE format but NaN and infinity are rejected on insert with an error.
SQLite REAL 8 bytes IEEE double: infinity stores (9e999 evaluates to Inf) but NaN quietly becomes NULL.
Oracle BINARY_FLOAT / BINARY_DOUBLE 4-8 bytes Native IEEE types with BINARY_FLOAT_NAN and BINARY_FLOAT_INFINITY constants and IEEE comparison rules.

Gotchas

Where the engines disagree. These tend to surface as bugs during a migration or a port.

  1. NaN is not one thing: PostgreSQL stores and sorts it (above every number), SQLite maps it to NULL, MySQL and SQL Server reject it, Oracle keeps it with IEEE semantics.
  2. Oracle's NUMBER is decimal and BINARY_DOUBLE is binary: 0.1 is exact in one and not the other, so a NUMBER compared with a BINARY_DOUBLE can fail an equality that looks obviously true.
  3. Divide by zero: SQL Server and PostgreSQL raise errors; MySQL returns NULL with a warning in a SELECT (an error in strict-mode writes); Oracle returns Inf for BINARY_FLOAT/BINARY_DOUBLE and ORA-01476 for NUMBER; SQLite returns NULL.
  4. JSON and most wire formats cannot carry NaN or Infinity: drivers return NULL or error when serializing them.

Common questions

What is BINARY_FLOAT in Oracle?

A native 4-byte IEEE 754 float, unlike the NUMBER-based FLOAT. BINARY_DOUBLE is its 8-byte sibling.

Can SQL Server store NaN or Infinity?

No. Both raise errors; IEEE special values need an encoding scheme, such as a sentinel column.

Why did my NaN become NULL in SQLite?

SQLite converts NaN to NULL on insert. Round-tripping such a value through SQLite can silently change its meaning.

// map types before you move data

Map a type to the other four engines

The free type converter maps a type from one engine to its closest equivalent in the others and says where storage, precision or behaviour differ. The desktop app does the same mapping while you edit.