GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Home
  • Basic Answers
  • References
  • xkcd
  • Binary Fractions
  • Floating-Point
  • Exact Types
  • On Using Integers
  • Rounding
  • Comparison
  • Propagation
  • C#
  • Java
  • JavaScript

This view

  • Original page
  • New address

GeezerVison is showing floating-point-gui.de — The Floating-Point Guide - What Every Programmer Should Know About Floating-Point Arithmetic

What Every Programmer Should Know About Floating-Point Arithmetic

or

Why don’t my numbers add up?

So you’ve written some absurdly simple code, say for example:

	0.1 + 0.2

and got a really unexpected result:

	0.30000000000000004

Maybe you asked for help on some forum and got pointed to a long article with lots of formulas that didn’t seem to help with your problem.

Well, this site is here to:

  • Explain concisely why you get that unexpected result
  • Tell you how to deal with this problem
  • If you’re interested, provide in-depth explanations of why floating-point numbers have to work like that and what other problems can arise

You should look at the Basic Answers first - but don’t stop there!

© Published at floating-point-gui.de under the Creative Commons Attribution License (BY)

The Floating-Point Guide

  • Home
  • Basic Answers
  • References
  • xkcd

Number Formats

  • Binary Fractions
  • Floating-Point
  • Exact Types
  • On Using Integers

Errors

  • Rounding
  • Comparison
  • Propagation

Language
cheat sheets

  • C#
  • Java
  • JavaScript
  • Perl
  • PHP
  • Python
  • Ruby
  • Rust
  • SQL
Fork me on GitHub
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.