Faults in Linux 3.x : Using Floating Point Values

As part of my work, I need to annotate  the reports generated using Coccinelle Scripts as bugs/FPs for recent Linux Kernels, recent as in versions > 3.0 till the current one 3.18.

So while reading the reports (newer ones), when I started Linux_floatop.new.org, there was only one TODO. Means they have not at all used floating point values in recent Linux Kernel.

This org file has the reports where floating point values in kernel code. I wrote a post on why it is bad to use floating point values in kernel?

The one todo that was there was a FP. It was intentional. The code snipped was something like this

static long ppb_to_scaled_ppm(int ppb)
* The 'freq' field in the 'struct timex' is in parts per
* million, but with a 16 bit binary fractional field.
* Instead of calculating either one of
* scaled_ppm = (ppb / 1000) << 16 [1]
* scaled_ppm = (ppb << 16) / 1000 [2]
* we simply use double precision math, in order to avoid the
* truncation in [1] and the possible overflow in [2].
return (long) (ppb * 65.536);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s