The majority of data can easily be plotted on a graph with equal intervals on the axes, for example 1, 2, 3 or 100, 200, 300 etc.. Some data, typically that which increases or decreases exponentially, cannot comfortably be graphed on such a scale without squashing the data up so much at one end that it becomes incomprehensible. The solution to this problem is to use a logarithmic scale.Continue reading
A very quick micro-post just to say that I have pushed the source code for all my posts to date to Github. The URL is
The source code for all future posts will also be on Github so feel free to follow me if you wish.
Writing code to read or write text files can be tricky because the exact contents of a file cannot be viewed in a text editor if the file contains non-printable characters such as line feeds or carriage returns. This simple utility program will take a filename as a command line argument and print out its exact contents, including descriptions of any non-printable or whitespace characters.
C99 introduced a new addition to the standard library to support complex numbers. The area of complex numbers is a vast one so in this post I will just give an overview of the C types and some of the associated functions, as well as writing a function to draw an Argand diagram using SVG.Continue reading
The Euclidean Algorithm is a simple method for finding the highest common factor or HCF (also known as greatest common divisor or GCD) of two positive integers. This is an implementation of the algorithm in C.Continue reading
There are many sorting algorithms, often with variations and optimizations, and every now and again I will be coding some of them for this site.
A while ago I wrote a post on bubble sort and here is a follow up on another sorting algorithm called selection sort. As with bubble sort it’s not particularly efficient but it is simple to understand and implement.
All the posts on this blog contain C source code which has been reformatted as HTML. This would be incredibly tedious to do by hand so I put together a quick and dirty utility to do it for me. It's not the greatest piece of software ever written but it does the job, so I thought I might as well share it.Continue reading