Converting Integers to Floats Using Hyperfocus

A few years ago, due to some random chain of events, I ended up implementing a conversion from 128 bit integers to 64 bit floats. This would’ve turned out to be a complete waste of time, except that my final version is faster than the builtin conversion of every compiler I tested. In this blog post, I’ll explain what happened, how floats work, how this conversion works, and how it got a bit out of hand.

Rust is not a Company

Last year, as an occasional contributor to the Rust project, I did not think much about the organisational structure of the team behind the project. I saw a hierarchy of teams and groups, team leaders, etc. Just like any other organisation. This year, after getting more involved, becoming a library team member and eventually team lead, I spent some more time thinking about why we have this structure, what these teams are for.

Writing Python inside your Rust code — Part 4

In this final part of the series, we’ll explore a trick to make the behaviour of a macro depend on whether it’s used as a statement or as part of an expression. Using that, we’ll make the python!{} macro more flexible to allow saving, reusing, and inspecting Python variables.

Compile time unit arithmetic in C++

In Software for Infrastructure, Bjarne Stroustrup shows a way to use templates to make the C++ compiler aware of the unit of a value (e.g. kilograms, seconds, etc.), such that it can check consistent use and prevent disasters like the well known error at NASA in 1999 caused by mixing incompatible units. In this article, I show how to extend this idea to support any number of base units and linearly related units (e.g. centimetres, metres and inches) by teaching the compiler how to do arithmetic on units.

C++11: Rvalue references for *this

Recently, gcc added support rvalue references for *this. (Clang has supported it for quite a while now.) In this post, I show how to use this feature, and how it means we can finally define accessors and a few other things like operator= correctly.