Tagged articles
floating-point
58 articles · Page 1 of 1
This article explains how JavaScript's reduce method loses precision when summing large or many numbers due to floating-point rounding, introduces the new ES2026 Math.sumPrecise() method that avoids intermediate rounding errors, demonstrates its accuracy with examples like summing 1e20, 0.1, -1e20 and 1000 times 0.1, and notes current browser support.
ES2026IEEE 754JavaScript
0 likes · 6 min read

This article explains why PHP's IEEE 754 floating-point arithmetic causes 0.1 + 0.2 ≠ 0.3, demonstrates integer overflow issues near PHP_INT_MAX, and details correct approaches: tolerance-based comparison, integer fixed-decimal scaling, and arbitrary-precision extensions BCMath and GMP with string inputs.
BCMathGMPIEEE 754
0 likes · 12 min read

Floating‑point calculations can yield different results on Windows, macOS and Linux due to JVM optimisations; the strictfp keyword forces Java to follow the IEEE‑754 standard exactly, disabling hardware‑level precision tricks so that the same code produces identical results on any OS, CPU or JVM implementation.
IEEE 754JavaStrictMath
0 likes · 18 min read


ITPUBApr 19, 2026 · Fundamentals
This article demystifies why adding two approximated 0.1 values yields an exact 0.2 in floating‑point arithmetic while adding 0.1 and 0.2 fails to produce an exact 0.3, by detailing IEEE‑754 double‑precision storage, binary conversion, rounding effects, and Java code verification.
IEEE 754InterviewJava
0 likes · 9 min read

The article explains why adding 0.1 and 0.2 in Rust (and other IEEE‑754 languages) yields 0.30000000000000004, explores the binary representation limits of f64, introduces the ULP concept, and details how the Ryū algorithm produces the shortest correct decimal string for floating‑point numbers.
RustRyū algorithmULP
0 likes · 11 min read

This article explores the surprising result that adding every IEEE‑754 floating‑point number between –1 and 1, even with exhaustive brute‑force enumeration in Rust, yields a non‑zero sum due to representation limits, rounding errors, and accumulation order effects.
IEEE 754Kahan-summationRust
0 likes · 7 min read
![Why Summing All Floats in [-1, 1] Doesn’t Produce Zero – A Brute‑Force Study](https://wsrv.nl/?url=https%3A%2F%2Fmmbiz.qpic.cn%2Fsz_mmbiz_jpg%2Fh1dibp9WKYiaObWtYVHfytWwhOaM4FIYVbNUcRsZlwJuic4ACYpkKjww4uU9u24I4TsRgDZsC1GEjfBZ6sXTSfwIrbNqbDXGqOzTCEhBkddianU%2F0%3Fwx_fmt%3Djpeg)
This article explains how microcontroller units (MCUs) handle floating‑point operations, covering IEEE‑754 representation, hardware versus software FPU approaches, performance and precision challenges, and a range of optimization techniques—from hardware selection and fixed‑point tricks to compiler flags and system‑level power management.
ARMEmbeddedFPU
0 likes · 10 min read

This article explains how integers and decimals are stored using fixed‑point and floating‑point representations, introduces the 8‑bit FP8 formats (E4M3 and E5M2) used in modern AI hardware, and traces the evolution from classic FP32/FP64 to the latest ultra‑compact numeric types.
AI hardwareFP8Fixed-Point
0 likes · 8 min read

This article explains the meaning of UE8M0 by introducing fixed‑point (INT8) and floating‑point representations, showing how integers and decimals are stored in binary, describing the limitations of fixed‑point, the advantages of floating‑point scientific notation, and detailing the emerging FP8 formats such as E4M3 and E5M2 used in modern AI hardware.
AI hardwareFP8Fixed-Point
0 likes · 8 min read

This article outlines four common pitfalls when using Java's BigDecimal for high‑precision calculations—constructing from floating‑point literals, using equals for comparison, losing precision in division, and rounding issues—and provides practical solutions such as using string constructors, compareTo, specifying scale and rounding mode.
bigdecimalfloating-pointprecision
0 likes · 5 min read

This article details how replacing Java's native double parsing with the Ryu and FastFloat algorithms, alongside JVM GC tuning, dramatically reduces CPU usage and latency in backend services, offering practical code examples, benchmark results, and actionable optimization strategies.
FastFloatGCJVM
0 likes · 15 min read

Floating‑point numbers cannot precisely represent many decimal values, leading to cumulative errors in financial calculations, so Java’s BigDecimal class is recommended for high‑precision arithmetic to avoid such inaccuracies and ensure reliable monetary computations.
Financial-CalculationsJavabigdecimal
0 likes · 2 min read

This article explains scientific notation, the IEEE‑754 floating‑point standard, the structure of FP32 and FP64 numbers, and how computational power is measured using FLOPS, illustrating CPU and GPU FP32 performance calculations and why FP32 is the common benchmark for AI workloads.
CPUFP32GPU
0 likes · 17 min read


ITPUBMar 8, 2025 · Backend Development
The article explains how using double for monetary values can cause precision loss—turning 2.01 into 2.00—illustrates the binary representation issue, demonstrates failing code, and presents a robust solution using Java's BigDecimal with sample conversion methods and performance tests.
JavaMoneybigdecimal
0 likes · 6 min read

This article reveals thirteen subtle Go programming mistakes—from octal literals and integer overflow to floating‑point comparison, slice length vs. capacity, map initialization, and value copying—providing clear explanations, real‑world analogies, and concrete best‑practice code fixes to prevent bugs and performance issues.
Best PracticesGofloating-point
0 likes · 14 min read

Python’s unexpected 0.1 + 0.2 = 0.30000000000000004 result stems from binary floating‑point representation limits defined by the IEEE 754 standard, and the article explains this issue, rounding modes, and practical solutions such as the decimal module, fractions, math.isclose, and high‑precision NumPy types.
IEEE 754NumPyPython
0 likes · 9 min read

This article explains why double precision numbers cannot represent many decimal values exactly, how BigDecimal achieves precise arithmetic through unscaled values and scale, and the proper ways to construct BigDecimal objects to avoid precision loss in Java applications.
bigdecimalfloating-pointprecision
0 likes · 10 min read

This article explains PHP's is_float() function, covering its syntax, behavior, practical usage, and provides multiple code examples demonstrating how to detect floating‑point numbers and combine the check with conditional logic in real‑world applications.
floating-pointis_floattype checking
0 likes · 5 min read

This article explains why using double for monetary values in Java can cause rounding errors such as 2.01 becoming 2.00, demonstrates the binary precision problem with sample code, and provides a robust BigDecimal‑based solution with performance testing.
bigdecimalfloating-pointmoney conversion
0 likes · 5 min read

The article explains why comparing floating‑point numbers with == in Java often yields unexpected results, describes the IEEE‑754 representation of float and double, demonstrates common pitfalls through code examples, and provides step‑by‑step methods for converting decimal fractions to binary.
IEEE 754Javabinary conversion
0 likes · 10 min read

The Fast Inverse Square Root algorithm, invented by John Carmack for Quake III Arena, uses a clever magic constant and Newton‑Raphson iteration to compute 1/√x far faster than traditional methods, dramatically reducing floating‑point workload in real‑time graphics.
AlgorithmCarmackFast Inverse Square Root
0 likes · 4 min read

The article explains why Python’s 0.1 + 0.2 does not equal 0.3 due to binary representation limits, discusses the impact of tiny rounding errors on equality checks, and recommends using tolerance thresholds or the Decimal module (initialized with strings) for accurate numeric computations, especially in finance.
DecimalNumerical ComparisonPython
0 likes · 3 min read

This article explains why Java's BigDecimal is essential for high‑precision arithmetic, outlines common use cases such as finance and scientific computing, highlights typical pitfalls with floating‑point numbers, and provides practical code examples and best‑practice tips for correct usage.
ArithmeticJavabigdecimal
0 likes · 8 min read

This article explains how floating‑point numbers are represented in computers using IEEE‑754, illustrates conversion from decimal to binary, describes single‑ and double‑precision formats, outlines common precision, rounding, comparison, overflow, and associativity problems, and presents practical solutions such as high‑precision decimal types, integer scaling, and specialized libraries.
DecimalIEEE754floating-point
0 likes · 9 min read

The article explains PHP's fmod() function for calculating the remainder of two floating‑point numbers, describes its syntax and parameter roles, provides multiple code examples—including handling of zero divisors and negative values—and notes that it returns a float or NAN when appropriate.
MathPHPfloating-point
0 likes · 4 min read

This article explains PHP's abs() absolute‑value function, covering its syntax, basic integer and floating‑point examples, precision issues with very small numbers, and how to combine it with round() to obtain accurate results, while noting its limitation to numeric types.
ABSTutorialabsolute-value
0 likes · 4 min read

This article explains why adding the decimal numbers 0.1 and 0.2 in binary floating‑point arithmetic yields the surprising result 0.30000000000000004, by detailing the exact 64‑bit representations, the rounding‑to‑nearest‑even rule, and step‑by‑step Python calculations that expose the underlying IEEE‑754 mechanics.
IEEE 754PythonRounding
0 likes · 10 min read

This article explains why using Java's BigDecimal is essential for precise financial calculations, outlines four common pitfalls—including floating-point errors, equality comparison, scale handling, and string conversion—and provides practical best-practice solutions with code examples and rounding mode guidance.
Financial-CalculationsRoundingModebigdecimal
0 likes · 14 min read

This article explains why floating‑point numbers lose precision in binary representation, demonstrates the issue with Java float examples, and shows how to use the BigDecimal class—including creation, arithmetic operations, scaling, and proper equality comparison—to achieve exact decimal calculations in Java applications.
ArithmeticJavabigdecimal
0 likes · 8 min read

This article explains several common mistakes when using Java's BigDecimal—such as constructing it with a double, using valueOf, relying on equals for comparison, and misusing round—and provides correct alternatives like string constructors, valueOf with proper precision, compareTo, and setScale for reliable arithmetic.
Best PracticesJavaMath
0 likes · 6 min read

This article analyzes a checkout‑system outage caused by BigDecimal precision loss, reproduces the bug with Java code, explains the underlying double‑to‑long conversion issue, and recommends using String‑based construction for accurate monetary calculations.
Financial-CalculationsJavabigdecimal
0 likes · 6 min read

This article explains why using floating‑point types with BigDecimal can cause precision loss in financial calculations, demonstrates the problem with sample code, analyzes the underlying double‑to‑long conversion, and provides a reusable Java utility class to perform accurate arithmetic with BigDecimal.
FinancialJavaUtility
0 likes · 8 min read

This article explains how JavaScript's parseInt function works, its handling of radix and floating‑point numbers, why it produces surprising results with very small values, and recommends safer alternatives like Math.floor for extracting integer parts.
JavaScriptMath.floorType Conversion
0 likes · 5 min read

This article demystifies the fast inverse square root algorithm used in games, explaining the origin of the infamous 0x5f3759df magic number, the underlying IEEE‑754 floating‑point representation, the evil bit‑hack, Newton iteration steps, and how these tricks accelerate vector normalization.
AlgorithmFast Inverse Square Rootbit hack
0 likes · 17 min read

The 1994 Intel Pentium FDIV floating‑point bug, caused by a handful of zero entries in a 2048‑entry lookup table, remained hidden for years until a mathematician spotted anomalies, prompting a worldwide collaborative effort that ultimately produced a clever scaling fix and massive media attention.
FDIV bugIntelcomputer architecture
0 likes · 10 min read

This article examines the popular Java humanReadableByteCount function, reveals hidden bugs in its handling of edge cases and floating‑point precision, presents a logarithm‑based solution, discusses empirical research on Stack Overflow code reuse, and offers a robust final implementation.
Byte CountHuman ReadableJava
0 likes · 12 min read

This article explains how MySQL implicitly converts mismatched column types—such as comparing a VARCHAR column with a numeric literal—into floating‑point numbers, causing seemingly equal values to match, losing index usage, and potentially producing incorrect query results.
MySQLType Conversionfloating-point
0 likes · 7 min read

This article explains PHP floating-point precision issues, demonstrates common arithmetic errors, and shows how to use the bcmath extension and various rounding functions such as floor, ceil, round, and number_format to achieve accurate numeric calculations in backend development.
BCMathBackendPHP
0 likes · 6 min read

BigDecimal provides precise arithmetic in Java, but its correct usage requires understanding its internal unscaled value and scale, avoiding the inaccurate BigDecimal(double) constructor, and preferring String or valueOf methods to accurately represent decimal numbers such as 0.1 in financial and e‑commerce applications.
FinancialJavabigdecimal
0 likes · 9 min read

JavaScript’s 0.2 + 0.1 yielding 0.30000000000000004 stems from binary floating‑point representation, where many decimal fractions cannot be expressed exactly; the article explains decimal‑to‑binary conversion, the repeating binary of 0.1, IEEE‑754 format, and how to avoid precision loss using BigDecimal in Java.
IEEE 754JavaJavaScript
0 likes · 9 min read

This article explains why JavaScript’s Number type, which follows the IEEE‑754 double‑precision standard, can produce unexpected results such as 0.1 + 0.2 = 0.30000000000000004, demonstrates the binary representation of numbers like 2.5 and 0.1, and offers practical techniques and libraries to mitigate floating‑point errors.
IEEE754JavaScriptbig-number
0 likes · 8 min read

This article explains why adding 0.1 and 0.2 in JavaScript (and most other languages) does not yield exactly 0.3, covering binary representation of decimal fractions, IEEE‑754 precision limits, single‑ and double‑precision formats, and practical implications for developers.
IEEE 754JavaScriptbinary
0 likes · 10 min read

This article explains how floating‑point arithmetic in Java leads to precision loss, shows that even BigDecimal can suffer the same issue when misused, and provides proper construction methods and a utility class to ensure accurate monetary calculations.
BackendJavaUtility
0 likes · 9 min read

The article explains why floating‑point arithmetic in Java loses precision, demonstrates how even BigDecimal can suffer when constructed from double values, and shows the correct practice of using the BigDecimal(String) constructor together with utility methods to perform accurate monetary calculations.
JavaMonetary Calculationsbigdecimal
0 likes · 9 min read

JavaScript’s unexpected result for 0.1 + 0.2 versus the exact 0.3 + 0.4 arises because numbers are stored in IEEE‑754 double‑precision binary, where limited mantissa bits require exponent alignment and rounding (ties‑to‑even), causing small representation errors that appear as 0.30000000000000004.
IEEE754Roundingfloating-point
0 likes · 7 min read

An intriguing experiment shows that a seemingly harmless "y += 0" operation can be seven times slower than "y += 0.1f" due to CPU handling of denormalized floating‑point numbers, and the article explains the binary representation, performance impact, and how to disable it for faster code.
C++CPU performancedenormal numbers
0 likes · 10 min read

An intriguing experiment shows that replacing a harmless "y += 0" with "y += 0.1f" makes a tight C++ loop run seven times faster, revealing how denormalized floating‑point numbers trigger costly CPU paths and how understanding IEEE‑754 representation can restore performance.
C++CPUdenormal
0 likes · 10 min read

This article examines why converting a double value that exceeds the long range yields opposite signs on x86 and ARM processors, explains the underlying CPU instruction differences, presents detailed conversion tables, and reviews essential floating‑point and two's‑complement integer concepts.
ARMCPU architectureKunpeng
0 likes · 9 min read

This article explains how the V8 JavaScript engine generates machine code for floating‑point addition on Intel x64, covering V8’s architecture, the IEEE‑754 representation that causes precision loss, and a step‑by‑step analysis of the relevant C++ source and the resulting addsd instruction.
CompilerJavaScriptMachine Code
0 likes · 12 min read

The latest Java Development Handbook introduces 21 new coding rules, revises over a hundred guidelines, and adds clearer examples on lock handling, switch‑null checks, floating‑point comparisons, collection conversions, and guard statements, while inviting developers to download the free PDF and join a live discussion.
Code ExamplesConcurrencyJava
0 likes · 9 min read

The newly released Java Development Handbook introduces three major upgrades—21 new coding rules, over a hundred revisions, and richer examples—while offering practical guidance on lock handling, switch NPE avoidance, floating‑point comparisons, guard statements, and other common Java pitfalls, all available for free download.
ConcurrencyJavacoding standards
0 likes · 9 min read

This article presents five Java code snippets—covering floating‑point comparison, wrapper equality, switch handling of null, BigDecimal construction, and lock usage—and challenges readers to identify the correct outcomes, exposing common misconceptions and best‑practice solutions.
ConcurrencyInterview questionsbigdecimal
0 likes · 4 min read

This article explains the fundamental differences between CPUs and GPUs, outlines key GPU specifications such as CUDA cores, memory capacity, bandwidth, and floating‑point precision, and reviews NVIDIA's major GPU series and architectural evolution for high‑performance and AI workloads.
CPUGPUNVIDIA
0 likes · 11 min read

This article explains why JavaScript’s Number type suffers from floating‑point precision errors, describes the IEEE‑754 double‑precision storage format, clarifies key Number properties, shows why 0.1 + 0.2 is not exactly 0.3, and provides practical code‑based solutions.
IEEE 754JavaScriptcode
0 likes · 9 min read

JavaScript’s NaN represents undefined numeric results, appears when operations like Math.sqrt(-1) occur, has multiple binary forms, and is distinguished as Quiet or Signaling; because NaN !== NaN, comparisons rely on special checks such as isnan, with implementations varying across environments like V8 and Apple’s C library.
C libraryJavaScriptNaN
0 likes · 8 min read

This article explains why all IEEE‑754 based languages suffer from floating‑point precision errors, illustrates common problematic calculations, and presents integer‑conversion techniques and library recommendations such as decimal.js to achieve accurate numeric results, especially for financial computations.
JavaScriptdecimal.jsfloating-point
0 likes · 4 min read


ITPUBMay 27, 2017 · Fundamentals
The article explains why adding 0.1 and 0.2 in JavaScript, Python or C produces 0.30000000000000004 instead of 0.3, by detailing binary floating‑point representation, IEEE‑754 encoding, exponent alignment, rounding rules, and shows C code that reveals the exact stored bits.
C++IEEE 754JavaScript
0 likes · 11 min read

This article details a query‑diff test that revealed a 1% floating‑point precision difference after a module upgrade, describes the systematic investigation of environment, compilation, and CPU instruction‑set variations (AVX vs SSE), and presents conclusions and recommendations for preventing similar issues.
AVXCPUSSE
0 likes · 10 min read
