# Floating point representation visualizer

Hi everyone,

I’ve been teaching an introductory course on the Theory of Computation at Plymouth University. The topic of my last lecture was the representation of real numbers in computers, and the unavoidable errors introduced by any choice of representation. Particularly, the lecture was focused on the floating point representation of real numbers.

To make the nature of the float representation more intuitive to the students, I programmed a little visualizer which plots the numbers that can be represented with a floating point representation, given the number of bits in the exponential and in the mantissa. Within the visualizer, it is possible to change the number of bits in the exponential and the mantissa and observe how the set of representable numbers change.

It is also possible to sum two numbers, **a** and **b**, and observe how errors come to be and get the visual intuition of why they are unavoidable (hopefully).

– Here, the ipython notebook I used during my lecture.

– Here, the zipped executable for the visualizer.

– Here the python code (you will need python 2.7, with matplotlib and numpy libraries).

*At the moment of writing the visualizer is still lacking some features. In particular, I’d like to make the representation more IEEE-754 compliant by adding support for signed 0’s, signed infinity, and NaN values. I’ll do that soon, but for the moment, I think the visualizer is already useful as it is.*

education visualization

Use the hashtag #FloatingPointRepresentation0330, and mention me with @GCarmantini if you want a direct reply.

## This conversation is happening on Twitter

Leave a comment