New answers tagged

0 votes

What is the difference between a pointer pointing to 0x0 location and a pointer set to NULL?

To illustrate the point in the other answers, years ago I wrote some C code to run on Inmos Transputers. They were strange things in several ways. One way was that memory addresses were signed ...
Simon B's user avatar
  • 9,561
0 votes

Why is int in C in practice at least a 32 bit type today, despite it being developed on/for the PDP-11, a 16 bit machine?

Int wasn’t 16 bit to support PDP/11 but to support a machine popular at the time. Today, we support machines that are popular today. You can get ARM-Cortex 64 bit processors for very little money. So ...
gnasher729's user avatar
  • 43.5k
0 votes

Why is int in C in practice at least a 32 bit type today, despite it being developed on/for the PDP-11, a 16 bit machine?

C was designed to be maximally portable, and while 8-bit bytes / 16-bit words / 32-bit longwords are common, they aren't universal. There are real-world architectures that use 9-bit bytes and 36-bit ...
John Bode's user avatar
  • 10.8k
0 votes

What is the purpose of NaN boxing?

You always run the risk that the extra bits in a NaN are not preserved, depending on the implementation. (What must be preserved is the silent/signalling bit, and the fact that some but is set). It’s ...
gnasher729's user avatar
  • 43.5k
5 votes
Accepted

Maintaining global states in a recursive function

Using global data is bad because your recursive function cannot be used from multiple threads. Which is a horrible trap, because 99.99% of the time it’s not called from multiple threads at the same ...
gnasher729's user avatar
  • 43.5k
7 votes

Maintaining global states in a recursive function

Global and in scope are different things. Either a closure or an object will give you a place to declare fields that are accessible from call to call, maintain state, and are not global. In closures ...
candied_orange's user avatar

Top 50 recent answers are included