What does Four Pillars and Double Entry conclude, in numbers, about “Exact Arithmetic: Integer Fen, an Exchange-Difference Account and Largest-Remainder Sharing”?
Answer: The fourth and fifth lines show a case a buying agent will meet in earnest. An order is priced at 750.40 yuan; the customer pays a deposit of 300.10 yuan and then a balance of 450.30 yuan. Testing in floating point whether deposit plus balance equals price gives False, because the float total is 750.4000000000001. In integer fen, 30010 plus 45030 equals 75040 and the test passes.
Scope of the numbers: With runnable programs this book shows that a single-entry list contains no test of itself: on an illustrative day, leave out a balance payment of 1,500.00 yuan and the spreadsheet stays perfectly consistent; a gap appears only against the bank balance. Parameters are illustrative; all calculations are generated by the book's programs; the book is general analysis, not individualised accounting, tax or legal advice.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 300.10, 30010, 450.30, 45030, 750.40, 750.4000000000001
| stored 0.1 | 3602879701896397/36028797018963968 |
| stored 0.1 - 1/10 | 1/180143985094819840 |
| fsum([0.1, 0.2]) = | 0.3 -> False (0.30000000000000004) |
| deposit 300.10 + balance 450.30 == price 750.40 -> False | |
| the float total is 750.4000000000001 | |
| 30010 + 45030 = | 75040 in fen -> True |
| round(2.675, 2) | 2.67 |
| Decimal half-up | 2.68 |
| integer half-up of 2675 tenths-of-fen | 268 fen |
| amounts 0.00 to 999.99 | 96000 of 100000 not stored exactly |
Show the full program
# Chapter 4. p41: why a ledger is kept in integer fen, not in floats.
# Model: binary floating point stores 0.1 as the nearest dyadic
# fraction. math.fsum adds the stored values exactly and rounds once,
# so it removes accumulation error but cannot undo the input error.
# A conservation test of the form "left == right" then fails on
# amounts that balance on paper. Integer fen (or Fraction) passes.
# Half-up rounding to fen is shown three ways: float round(), Decimal
# with ROUND_HALF_UP, and pure integer arithmetic on fen times 10.
from decimal import Decimal, ROUND_HALF_UP
from fractions import Fraction as F
import math
def half_up_fen(tenths_of_fen):
"""Round an integer count of 0.1 fen to whole fen, half away."""
q, r = divmod(abs(tenths_of_fen), 10)
q += r >= 5
return q if tenths_of_fen >= 0 else -q
if __name__ == "__main__":
print("stored 0.1 = {}".format(F(0.1)))
print("stored 0.1 - 1/10 = {}".format(F(0.1) - F(1, 10)))
a = math.fsum([0.1, 0.2])
print("fsum([0.1, 0.2]) == 0.3 -> {} ({!r})".format(a == 0.3, a))
left = math.fsum([300.10, 450.30])
print("deposit 300.10 + balance 450.30 == price 750.40 -> {}".format(
left == 750.40))
print(" the float total is {!r}".format(left))
print("30010 + 45030 == 75040 in fen -> {}".format(
30010 + 45030 == 75040))
print("round(2.675, 2) = {}".format(round(2.675, 2)))
d = Decimal("2.675").quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
print("Decimal half-up = {}".format(d))
print("integer half-up of 2675 tenths-of-fen = {} fen".format(
half_up_fen(2675)))
bad = 0
for cents in range(0, 100000):
x = cents / 100
if F(x) != F(cents, 100):
bad += 1
print("amounts 0.00 to 999.99: {} of 100000 not stored exactly".format(
bad))Single source and citation
Fan, Y. (2026). The Conservation Algebra of Four-Pillar Settlement and Double-Entry Bookkeeping: Invariants for Error-Free Reconciliation of Buying-Agent Ledgers (Version 1.0.0), Chapter 4: Exact Arithmetic: Integer Fen, an Exchange-Difference Account and Largest-Remainder Sharing. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-318 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026318,
author = {Fan, Yafu},
title = {The Conservation Algebra of Four-Pillar Settlement and Double-Entry Bookkeeping: Invariants for Error-Free Reconciliation of Buying-Agent Ledgers},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 1 · What a Single-Entry List Cannot See: Conservation Tests Only Against a Count
- Chapter 2 · The Detection Matrix of Nine Error Types: What the Trial Balance Catches and What It Lets Through
- Chapter 3 · The Algebra of Location: Incidence Matrix, Null Space and the Closing Window
- Chapter 5 · Accounts for a Buying Agent: Four Pillars for Every Account and Seven Daily Invariants
- Chapter 6 · How Many Orders to Re-check Each Week: Discovery Sampling and Value Strata
- Chapter 7 · Eastern and Western Sources: the Song Four-Pillar Settlement and Pacioli's Three Books
- Chapter 8 · Closing the Loop: the Daily Close, the Four-Pillar Double-Entry Reconciler and a Pre-registered Test