☑ (A)IEEE, maths!

Writing some notes on IEEE 754 led to discovering a nifty way to render formulae on the web.

maths blackboard

For my sins I recently had to do some work on IEEE 754 format floating point numbers. For the uninitiated1, IEEE 754 is a standard which specifies the underlying binary representation of floating point numbers, and the rules for their manipulation. Typically it’s not something that you need to worry about because compilers handle it for you, but in this case I couldn’t make any assumptions about the underlying hardware and the representation really had to be compliant.

As usual when I encounter something new, I set about pulling together my own little reference on the subject, and this led me to another issue — I needed to write some simple mathematical formulae on my wiki page, but HTML is really quite deficient in its ability to express such things. I did discover that a GTK text box can accept arbitrary unicode characters by holding down CTRL and SHIFT and typing U followed by four hex digits - this lasted all of about three seconds before I got sick and tired of continually2 looking up code points.

It was at this point a quick bit of Googling led me to MathJax, which is a great little Javascript-based solution to displaying formulae in browsers. Essentially you enter it in LaTeX format3 and the library handles rendering it elegantly in whatever browser is in use. Since I use Dokuwiki, I was also pleasantly surprised to see that there’s event a plugin for it already. You don’t even need to host the library yourself, since they have their own CDN for that, which means there’s a decent chance it’s already cached in a given browser anyway.

So, I still had to wrap my head around strange floating point conversion issues, but at least I had a pleasant way to write about it, which almost4 made up for it.

  1. You lucky, lucky people. 

  2. For “continually” read “twice”. 

  3. Or MathML if you’re a total masochist. 

  4. For “almost” read “not even slightly”. 

25 Feb 2013 at 1:18PM by Andy Pearce in Software  | Photo by Roman Mager on Unsplash  | Tags: maths  web floatingpoint