Intel Underestimates Error Bounds by 1.3 quintillion

gokul krishnan:

Do checkout Pentium FDIV bug too

Originally posted on Random ASCII:

imageIntel’s manuals for their x86/x64 processor clearly state that the fsin instruction (calculating the trigonometric sine) has a maximum error, in round-to-nearest mode, of one unit in the last place. This is not true. It’s not even close.

The worst-case error for the fsin instruction for small inputs is actually about 1.37 quintillion units in the last place, leaving fewer than four bits correct. For huge inputs it can be much worse, but I’m going to ignore that.

I was shocked when I discovered this. Both the fsin instruction and Intel’s documentation are hugely inaccurate, and the inaccurate documentation has led to poor decisions being made.

The great news is that when I shared an early version of this blog post with Intel they reacted quickly and the documentation is going to get fixed!

View original 2,252 more words

Nested Functions in C

Yes, you read the title right. No, I’m not crazy , OK maybe a bit (no pun intended). Maybe I’m sleep deprived, I honestly don’t remember when was the last time I had a good night’s sleep but it is true, C does support nested functions, All that you learnt about C was wrong (Gasp!!) Don’t trust me? Fine, go ahead and try the following code out.


         int main()

           void foo () {}return 0;


  GCC compiles it without a hitch. See, I told you! (again, no pun intended)I search around and figured out that ANSI ( C99 ) does not allow for nested functions. However, an addon for GCC provides support for it. I haven’t checked out its scoping rules or made any progress along that path. Do let me know if you find this out.


Numbers every Programmer should know

When discussing about Memory Hierarchy in today’s ( 25th Sept. 2014) OS class, I assumed that for those paying attention the sheer magnitude in access times between the different levels of the hierarchy should’ve been mind-blowing to say the least.

While the discussion continued, I recollected something I read a long time back. It went by the Title “Numbers every Programmer should know”. It was a listing of reference time for accessing various memories (Cache, Registers, HDD, Internet .etc) . The numbers were part of a talk given by the legendary programmer , co-inventor of mapReduce and Google Fellow Jeff Dean during an internal talk on building large scale distributed systems. This was later publicized by Peter Norvig, Head of Research at Google. The list is extremely interesting and the way the numbers have evolved over time show the pace at which technology is developing. Take a look for yourself.

Try guessing where current day computers are spending most of their time on? You’ll realize that they spend most of their time waiting, waiting for data to process.
This is fine for personal computers but in data centers, servers and other applications where performance is the key, this is just not acceptable. This was one of the main reasons for developing event-driven models for servers. Nginx and node.js are two examples of event-driven servers

This video gives a very good introduction to node.js. It also talks about the waiting problem and how node seeks to solve it.


As an addendum you can check out the numbers in big data, 6 PB, that’s the amount of chat data facebook has ( all our Awww!!! , Ohhh, hmm, :), :( , :\, >.< , :P all are there)


Pass-by-Reference in C

Unlike modern programming language, C has always been mysterious to even the most experienced of developers.
There’s always some feature of C that will surprise you even when you’re sure you know it inside out.

This is because C was written during a time when men were men and wrote their own operating systems in machine language.

So it was quite common for the creator of the language to put in quirks that made sense only to him. No one back then thought computers
would become common place.

So when the digital era kicked it, UNIX and C were behind its success, pushing it even further.

And C has faithfully carried forward these quirks to this date and I’m surprised every time I discover one.

Here’s an hypothetical, an interviewer tells you “C has only pass-by-value” , how would you support his argument?

It’s your first interview, and you’re already Stephen mcSweaty-Pants and he throws you this bouncer.

Quick! Think!!

Consider the following code snippet

void foo ( int * bar, int * baz)

//Do Something

You show this code to him and point to the header, pointers!!
you will be passing references to integer variables, surely this is pass-by-reference?

He still insists that C has only pass-by-value, you now think that he’s gone mad and that you probably won’t land this job.

Then he tells you consider how you would call the function

int x,y;
foo( &x, & y);

Now take a long look at that second line.

“Yeah, I’m passing references to x and y as required”

True, but try elaborating it a bit more (no puns intended)

“You are passing the VALUES of the memory address at which the values are stored”


To elaborate, the memory addresses of the actual parameters are copied onto the locations pointed to by the formal parameters
and and then the evaluation occurs.

So even when you’re passing references, you’re passing values of the addresses, which is effectively pass-by-value :)

Question: So how would you pass by reference in any language?

Turns out, Pascal supports pass by reference by using the var keyword.

procedure swap ( var x: integer, var y : integer);
var z : integer;
z :=x; x:=y; y:=z;

In Pascal, a formal parameter becomes a synonym for the location of an actual parameter.
keyword var is used to indicate this.

Inspired by and Pascal code snippet from “Programming Languages : concepts & constructs, Second edition” by Ravi Sethi