A float is a number stored in a computer as an approximate value, usually a floating-point number. It represents real numbers across a wide range by using sign, exponent and mantissa fields, which makes it suitable for measurements and calculations but not exact decimal arithmetic.
How floating-point numbers work
A float stores a number in a sign, exponent, and mantissa structure so software can represent very large and very small values efficiently. That design is what makes floating-point arithmetic practical for science, graphics, and measurement, but it also means the stored value is an approximation rather than an exact decimal.
The key idea is scale. Instead of keeping every digit with fixed decimal precision, the exponent shifts the range while the mantissa preserves significant digits. That allows the same format to represent values across many orders of magnitude, which is why floats are the default choice in most numerical systems.
Why floats are useful in computing
Floats are valuable when a system needs range and speed more than exactness. They let software model physical quantities, sensor readings, financial estimates, simulation output, and visual calculations without requiring a separate representation for each magnitude.
This flexibility comes with a trade-off: two values that look equal in decimal form may not compare exactly after conversion to binary floating point. That is not a defect in the language or runtime, it is the consequence of representing a dense set of real numbers with a finite number of bits.
Precision, rounding, and common surprises
Because floats are approximate, rounding error is normal and cumulative error can appear after repeated operations. Small differences can matter when code compares values directly, sums many terms, or depends on stable thresholds.
Typical surprises include 0.1 plus 0.2 not being stored as exactly 0.3, or values changing slightly after serialization and deserialization. In practice, developers usually compare floats with a tolerance, round deliberately for presentation, and choose decimal or integer representations when exact arithmetic is required.
Where floats fit in software design
Choosing float is a data-model decision as much as a programming one. It works best for measurement, statistics, graphics, signal processing, and other domains where approximate real-number behaviour is acceptable and expected.
It is a poor fit for identifiers, counters that must remain exact, and any workflow where decimal correctness is contractual or regulatory. Good software design treats float as a specialised numeric tool, not a universal number type, and selects it only when approximation is an acceptable part of the problem.
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 3, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org