Continuing from last week’s Lesson, I discovered that though the C language lets you create a Boolean array, the data is stored in char-sized integers and not true binary data. But there is a way to convert that Boolean area into binary data; it just takes some coding legerdemain.
Continue reading
Too Big – Solution
This month’s Exercise is about finding the limits, or how large a signed or unsigned char value can get before it flips over to negative or to zero. And the trick is performing this feat in your code without using the defined constants for a char data type available in the limits.h header file.
Continue reading
Keeping Up with the Booleans
As a programmer well-versed in Assembly Language, I’m all too familiar with the bits that populate a byte. At the low, low level you find plenty of tools to do bit manipulation. The C language has bitwise operators as well, which remains one of its advantages over the newer, trendier programming languages. So, how does all this fun activity cross over into the realm of the _Bool or bool data type in C?
Continue reading
Too Big
Difficulty: ★ ★ ☆ ☆
The C language comes with a variety of data types that hold integer (whole number) values. But each type is limited by its size. The issue is to ensure that whatever value the program is manipulating never exceeds the given size.
Continue reading
Booleans
One of the weaknesses of the C language when measured against the newer, trendier programming languages is that it lacks a Boolean type. That is, a variable that’s either one or zero. This issue was addressed with the C99 standard and its addition of the underscore _Bool data type. It’s furthered in the C23 standard with the (better) bool type as well as the true and false keywords available in just about every other programming language used today. It’s time for a deep dive into the binary pool of bool.
Continue reading
Two File Descriptors?
Having two file descriptors available to access the same file might seem redundant. In a way it is. It’s like having two sets of keys to a car: Yes, one could be a backup, but it’s more common that two different people are using the same car. But first, an example is necessary.
Continue reading
Duping a File in the Raw
One of C library functions I find most odd is dup(). I pronounce this function as if it rhymes with cup. I assume others may pronounce it like doop, which rhymes with poop. Whatever. The key is what the function does and how it could even remotely be necessary.
Continue reading
Ramanujan Nested Radicals – Solution
The topic for this month’s Exercise is to code a recursive function that solves the Ramanujan Nested Radical, illustrated in Figure 1. Remember that Ramanujan created and solved this puzzle in his head. #genius
Continue reading
Rubbing a File Raw
About six years ago, I wrote about opening a file in the raw. Specifically, using the open() function to access file data at a low level. This approach uses file descriptors (integers) to track file I/O as opposed to the file handles used by the high-level fopen() family of functions. It turns out that you can do more with raw file access than just read and write data.
Continue reading
Ramanujan Nested Radicals
Difficulty: ★ ★ ★ ★
Srinivasa Ramanujan was a mathematician of the genius variety in that he did amazing things in his short lifetime. The man was insanely brilliant. In fact, he struggled to get other mathematicians to understand his work because it was so unfamiliar. Anyway, he concocted the thing shown in Figure 1, which is one of many Ramanujan Nested Radicals:
Continue reading