Blog

Rounding float to nearest integer, part 2
Pascal Cuoq on 3 May 2013

The previous post offered to round a positive float to the nearest integer represented as a float through a conversion back and forth to 32-bit unsigned int. There was also the promise of at least another method. Thanks to reader feedback there will be two. What was intended to be...

Read More

Harder than it looks: rounding float to nearest integer, part 1
Pascal Cuoq on 2 May 2013

This post is the first in a series on the difficult task of rounding a floating-point number to an integer. Laugh not! The easiest-looking questions can hide unforeseen difficulties, and the most widely accepted solutions can be wrong. Problem Consider the task of rounding a float to the nearest integer....

Read More

A conversionless conversion function
Pascal Cuoq on 1 May 2013

A rant about programming interview questions Software development is a peculiar field. An applicant for a more traditionally artistic position would bring a portfolio to eir job interview: a selection of creations ey deems representative of eir work and wants to be judged by. But in the field of software...

Read More

Of compiler warnings discussions
Pascal Cuoq on 26 April 2013

A discussion I often have addresses the question of whether a compiler¹ can warn for all possible illegal actions a program could take at run-time within a specific, well-understood family² . (1) or some other piece of software that receives a program as input and, in finite time, does something...

Read More

Sign extension
Pascal Cuoq on 25 April 2013

There is no “sign extension” in C. Please stop referring to “sign extension” in C programs. In assembly, there is such a thing as “sign extension” Sign-extend is an assembly instruction say movsx %al %ebx to transfer the contents of a narrow register say %al to a wide register say...

Read More