Decimals numbers are a data type that aims to exactly represent decimal numbers. Some programmers may not know, or fully realize, that, in most programming languages, the numbers that you enter look like decimal numbers but internally are represented as binary—that is, base-2—floating-point numbers. Things that are totally simple for us, such as
0.1, simply cannot be represented exactly in binary. The decimal data type—whatever its stripe or flavor—aims to remedy this by giving us a way of representing and working with decimal numbers, not binary approximations thereof. (Wikipedia has more.)
There is no intention to filter out an language in particular; I'm just working with a slice of languages found in in the StackOverflow list linked to earlier. If a language does not have decimals, there may well be multiple third-part decimal libraries. I'm not aware of all libraries, so if I have linked to a
minor library and neglect to link to a more high-profile one, please let me know. More importantly, if I have misrepresented the basic fact of whether decimals exists at all in a language, send mail.
C does not have decimals. But they're working on it! The C23 standard (as in, 2023) standard proposes to add new fixed bit-width data types (32, 64, and 128) for these numbers.
C# has decimals in its underlying .NET subsystem. (For the same reason, decimals also exist in Visual Basic.)
C++ does not have decimals. But—like C—they're working on it!
Dart does not have decimals. But a third-party library exists.
Go does not have decimals, but a third-party library exists.
Java has decimals.
Kotlin does not have decimals. But, in a way, it does: since Kotlin is running on the JVM, one can get decimal functionality by using Java's built-in support.
PHP does not have decimals. An extension exists and at least one third-party library exists.
Python has decimals.
Ruby has decimals. Despite that, there is some third-party work to improve the built-in support.
Rust does not have decimals, but a crate exists.
SQL has decimals (it is the
DECIMAL data type). (Here is the documentation for, e.g., PostgreSQL, and here is the documentation for MySQL.)
Swift has decimals
inherit decimals, eventually.