HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
haberman
dumpfp
C++2012–2014
haberman / dumpfp

dumpfp

A small little tool for dumping a floating-point number in its native format

2Distinct people
3Mentions
0Explicit recommenders
57GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

A small little tool for dumping a floating-point number in its native format

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by month3 dated mentions

Observed mentions: 2012-11-21 23:11:53 UTC to 2014-03-27 16:18:20 UTC.

0122012-11-01 00:00:00 UTC to 2012-12-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 commentsNov 20122012-12-01 00:00:00 UTC to 2013-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-01-01 00:00:00 UTC to 2013-02-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-02-01 00:00:00 UTC to 2013-03-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-03-01 00:00:00 UTC to 2013-04-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-04-01 00:00:00 UTC to 2013-05-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-05-01 00:00:00 UTC to 2013-06-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-06-01 00:00:00 UTC to 2013-07-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-07-01 00:00:00 UTC to 2013-08-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 commentsJul 20132013-08-01 00:00:00 UTC to 2013-09-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-09-01 00:00:00 UTC to 2013-10-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-10-01 00:00:00 UTC to 2013-11-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-11-01 00:00:00 UTC to 2013-12-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-12-01 00:00:00 UTC to 2014-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2014-01-01 00:00:00 UTC to 2014-02-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2014-02-01 00:00:00 UTC to 2014-03-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2014-03-01 00:00:00 UTC to 2014-04-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsMar 2014

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
Nov 20122012-11-01 00:00:00 UTC2012-12-01 00:00:00 UTC202
Dec 20122012-12-01 00:00:00 UTC2013-01-01 00:00:00 UTC000
Jan 20132013-01-01 00:00:00 UTC2013-02-01 00:00:00 UTC000
Feb 20132013-02-01 00:00:00 UTC2013-03-01 00:00:00 UTC000
Mar 20132013-03-01 00:00:00 UTC2013-04-01 00:00:00 UTC000
Apr 20132013-04-01 00:00:00 UTC2013-05-01 00:00:00 UTC000
May 20132013-05-01 00:00:00 UTC2013-06-01 00:00:00 UTC000
Jun 20132013-06-01 00:00:00 UTC2013-07-01 00:00:00 UTC000
Jul 20132013-07-01 00:00:00 UTC2013-08-01 00:00:00 UTC000
Aug 20132013-08-01 00:00:00 UTC2013-09-01 00:00:00 UTC000
Sep 20132013-09-01 00:00:00 UTC2013-10-01 00:00:00 UTC000
Oct 20132013-10-01 00:00:00 UTC2013-11-01 00:00:00 UTC000
Nov 20132013-11-01 00:00:00 UTC2013-12-01 00:00:00 UTC000
Dec 20132013-12-01 00:00:00 UTC2014-01-01 00:00:00 UTC000
Jan 20142014-01-01 00:00:00 UTC2014-02-01 00:00:00 UTC000
Feb 20142014-02-01 00:00:00 UTC2014-03-01 00:00:00 UTC000
Mar 20142014-03-01 00:00:00 UTC2014-04-01 00:00:00 UTC101

What Hacker News says

3 sources
I find it illuminating to look at the exact values of the floating point numbers. This takes away an air of mystery: floating point numbers do in fact have very specific values, which we can inspect exactly. Here's 0.1 + 0.2 + 0.3: 0.1 (0.1000000000000000055511151231257827021181583404541015625) + 0.2 (0.200000000000000011102230246251565404236316680908203125) = 0.3000000000000000166533453693773481063544750213623046875 rounded: 0.3000000000000000444089209850062616169452667236328125 + 0.3 (0.299999999999999988897769753748434595763683319091796875) = 0.600000000000000033306690738754696212708950042724609375 rounded: 0.600000000000000088817841970012523233890533447265625 The operands can't be represented exactly as floating point so they are rounded to the nearest floating-point number before t
Read the rest
he addition even happens. And once the addition does happen, it is rounded to the nearest representable floating point value. Now we can look at the same for 0.1 + (0.2 + 0.3): 0.2 (0.200000000000000011102230246251565404236316680908203125) + 0.3 (0.299999999999999988897769753748434595763683319091796875) = 0.500000000000000000000000000000000000000000000000000000 rounded: 0.500000000000000000000000000000000000000000000000000000 + 0.1 (0.1000000000000000055511151231257827021181583404541015625) = 0.6000000000000000055511151231257827021181583404541015625 rounded: 0.59999999999999997779553950749686919152736663818359375 It's interesting to note that the first addition ends up being exact! This is a bit lucky, because 0.5 is exactly representable in floating point and the initial operands got rounded in opposite directions. It's also interesting that 0.6... only turns into 0.599999... at the point that we round the answer. You can play around with this stuff conveniently using the Python "Decimal" module. $ python Python 2.7.5 (default, Aug 25 2013, 00:04:04)- [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from decimal import Decimal, getcontext >>> getcontext().prec = 1000 # To prevent truncation/rounding >>> Decimal(0.1) Decimal('0.1000000000000000055511151231257827021181583404541015625') >>> a = Decimal(0.1) + Decimal(0.2) >>> a Decimal('0.3000000000000000166533453693773481063544750213623046875') >>> Decimal(float(a)) # get the value rounded to the nearest fp number Decimal('0.3000000000000000444089209850062616169452667236328125') You can also use my tool "dumpfp" (https://github.com/haberman/dumpfp) to inspect the value of a floating-point number in detail: $ ./dumpfp 0.1 Single Precision (IEEE 32-bit): raw = 0x3dcccccd sign = 0x0 exponent = 0x7b (-4) significand = 0x4ccccd VALUE CALCULATION = significand (1 + 5033165/2^23 (1.60000002384185791015625)) * 2^exponent (2^-4) = VALUE (13421773/2^27 (0.100000001490116119384765625)) Double Precision (IEEE 64-bit): raw = 0x3fb999999999999a sign = 0x0 exponent = 0x3fb (-4) significand = 0x999999999999a VALUE CALCULATION = significand (1 + 1351079888211149/2^51 (1.600000000000000088817841970012523233890533447265625)) * 2^exponent (2^-4) = VALUE (3602879701896397/2^55 (0.1000000000000000055511151231257827021181583404541015625))
In Why doesn't GCC optimize a*a*a*a*a*a to (a*a*a)*(a*a*a)? (2013)
Yes, 1.6 is. But the actual value being stored is between 1.6 and 1.6000000000000001 (in the double case) -- you have to round it to display it as decimal. I'm working on a program right now to give a detailed dump of a double/float's value, to make this as clear as possible (and I'm learning a lot in the process). EDIT: got an initial revision out there; check out: https://github.com/haberman/dumpfp
In What Every Computer Scientist Should Know About Floating-Point Arithmetic

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.