Floating-point numbers vs real numbers Understanding floating-point numbers is essential when working with decimal values. Floating-point numbers may also be used to work with whole numbers that do not fit in a long integer (at the expense of losing precision). In any case, you don’t want to be caught off guard when seeing this: In …
Category: Uncategorised
Invisible files
i-nodes and hard links Unix-like operating systems store file information in a data structure called i-node table. File names are just a way to reference an i-node and the same i-node may be referenced by more than one name. These associations between file names and i-nodes are called hard links. When a file is deleted, …
Negabinary base
The negabinary base, and in general any negative-base system, allows the representation of negative numbers without the need of using a minus sign. Calculation by hand To get some intuition about how this works, let’s consider the negabinary base (). In this base, each position represents a power of : and therefore: 4-2 4-2+1 4+1 …
How to migrate WordPress
This is a post based on my recent experience to upgrade this blog, a post about WordPress written in WordPress 😉 After three years, my WordPress website was way out of date and the warnings to update it were getting louder and louder: PHP version, WordPress version, theme version, plugins version… The last thing I …
Testing the limits of your application
When we first learn to program, we are taught to be mindful of the computer’s resources; they must be used sparingly and released as soon as possible. So you know the drill: close files, release database connections, close sockets, free memory, etc. But have you ever wondered who sets the limits of what can be …
Read the full post →“Testing the limits of your application”
This would not happen with Java
One of the main differences between C and Java is the capability of C to perform low-level memory operations. This allows for great power and flexibility but is also a constant source of bugs. In that sense, Java is considered a safer programming language. This post presents some examples in C that would not happen …
How to create a sparse file
Sparse files are files with “holes”. File holes do not take up any physical space as the file system does not allocate any disk blocks for a hole until data is written into it. Reading a hole returns a null byte. An example of sparse files is virtual machine images. For instance, when I create …
Future beginning and end in Scala
A common issue noticed when reviewing pull requests is the understanding of the boundaries of Futures. In most cases, people take for granted that given a function with this signature the full body of the function will be executed in the Future. Let’s look closely into this with a couple of examples Example 1 Here’s …
Java Date and Time API explained by example
The handling of dates and times is a sure source of pain and confusion. While time is a familiar concept that everybody knows intuitively, it is difficult to formalise when developing an application. This post aims to shed some light by presenting different use cases implemented with Java Date and Time API. Flight tickets The …
Read the full post →“Java Date and Time API explained by example”
How to construct objects in Scala
Scala’s object-oriented programming style comes with some syntactic sugar and a few tricks. In order to get a better understanding of how Scala works, we will examine a few Scala examples and the corresponding byte code (in reality, the Java code resulting from decompiling the class files). Examples Empty class Simplest possible example, an empty …